готово
74
.gitignore
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
|
43
Factory.pro
Normal file
@ -0,0 +1,43 @@
|
||||
QT += core gui sql
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
presenter.cpp \
|
||||
service/filterparams.cpp \
|
||||
service/projectlogic.cpp \
|
||||
service/serviceloaddb.cpp \
|
||||
service/types.cpp \
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
presenter.h \
|
||||
service/filterparams.h \
|
||||
service/projectlogic.h \
|
||||
service/serviceloaddb.h \
|
||||
service/types.h \
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
data/requestDeviceModels.sql \
|
||||
data/requestProjects.sql \
|
||||
data/requestStages.sql \
|
||||
data/requestWorkers.sql \
|
||||
|
||||
RESOURCES += \
|
||||
resources/resources.qrc
|
8
data/requestDeviceModels.sql
Normal file
@ -0,0 +1,8 @@
|
||||
SELECT
|
||||
m.*,
|
||||
dt.Name AS device_type_name
|
||||
FROM
|
||||
Model m
|
||||
JOIN
|
||||
DeviceType dt ON m.DeviceTypeID = dt.ID;
|
||||
|
10
data/requestProjects.sql
Normal file
@ -0,0 +1,10 @@
|
||||
SELECT
|
||||
p.*,
|
||||
t.Name AS team_name,
|
||||
s.Name AS stage_name
|
||||
FROM
|
||||
Project p
|
||||
JOIN
|
||||
Team t ON p.TeamID = t.ID
|
||||
JOIN
|
||||
Stages s ON p.StagesID = s.ID;
|
8
data/requestStages.sql
Normal file
@ -0,0 +1,8 @@
|
||||
SELECT
|
||||
s.*,
|
||||
w.Name AS worker_name
|
||||
FROM
|
||||
Stages s
|
||||
JOIN
|
||||
Worker w ON s.WorkerID = w.ID;
|
||||
|
8
data/requestWorkers.sql
Normal file
@ -0,0 +1,8 @@
|
||||
SELECT
|
||||
w.*,
|
||||
t.Name AS team_name
|
||||
FROM
|
||||
Worker w
|
||||
JOIN
|
||||
Team t ON w.TeamID = t.ID;
|
||||
|
10
main.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "presenter.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qDebug() << QSqlDatabase::drivers();
|
||||
QApplication a(argc, argv);
|
||||
new Presenter();
|
||||
return a.exec();
|
||||
}
|
499
mainwindow.cpp
Normal file
@ -0,0 +1,499 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowIcon(QIcon(":/images/mw-icon.png"));
|
||||
|
||||
int width = frameGeometry().width();
|
||||
int height = frameGeometry().height();
|
||||
QScreen *screen = qApp->primaryScreen();
|
||||
int screenWidth = screen->geometry().width();
|
||||
int screenHeight = screen->geometry().height();
|
||||
setGeometry((screenWidth/2)-(width/2), (screenHeight/2)-(height/2), width, height);
|
||||
|
||||
returnToDeviceList();
|
||||
|
||||
ui->tableWidget->verticalHeader()->setVisible(false);
|
||||
ui->tableWidget->setColumnCount(2);
|
||||
QStringList headers = QString("ID, Название").split(',');
|
||||
ui->tableWidget->setHorizontalHeaderLabels(headers);
|
||||
QHeaderView *header = ui->tableWidget->horizontalHeader();
|
||||
header->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
header->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
QFont headerFont = header->font();
|
||||
headerFont.setBold(true);
|
||||
header->setFont(headerFont);
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
ui->listWidgetProjects->setSpacing(10);
|
||||
|
||||
ui->checkBoxIsWorking->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
ui->checkBoxIsWorking->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
QStringList filterItems = {
|
||||
"Все пороекты",
|
||||
"Типы устройств",
|
||||
"Этапы",
|
||||
"Команды",
|
||||
"Работники",
|
||||
"Модели устройств"
|
||||
};
|
||||
|
||||
ui->comboBoxFilters->addItems(filterItems);
|
||||
|
||||
QStringList sortItems = {
|
||||
"Сначала дешевые",
|
||||
"Сначала дорогие",
|
||||
"Сначала с лайком"
|
||||
};
|
||||
|
||||
ui->comboBoxSort->addItems(sortItems);
|
||||
|
||||
QLineEdit *searchEdit = ui->lineEditSearch;
|
||||
QPushButton *searchButton = new QPushButton(this);
|
||||
|
||||
searchButton->setCursor(Qt::PointingHandCursor);
|
||||
searchButton->setStyleSheet("background: transparent; border: none;");
|
||||
searchButton->setIcon(QIcon(":/images/search.png"));
|
||||
searchButton->setFixedSize(22, 22);
|
||||
|
||||
QMargins margins = searchEdit->textMargins();
|
||||
searchEdit->setTextMargins(margins.left(), margins.top(), searchButton->width(), margins.bottom());
|
||||
searchEdit->setPlaceholderText(QStringLiteral("Поиск проектов по модели или типу..."));
|
||||
searchEdit->setMaxLength(200);
|
||||
|
||||
QHBoxLayout *searchLayout = new QHBoxLayout();
|
||||
searchLayout->addStretch();
|
||||
searchLayout->addWidget(searchButton);
|
||||
searchLayout->setSpacing(0);
|
||||
searchLayout->setContentsMargins(3, 2, 3, 2);
|
||||
searchEdit->setLayout(searchLayout);
|
||||
|
||||
QButtonGroup *buttonGroup = new QButtonGroup(this);
|
||||
buttonGroup->addButton(ui->radioButtonWorking);
|
||||
buttonGroup->addButton(ui->radioButtonNotWorking);
|
||||
buttonGroup->addButton(ui->radioButtonDisregard);
|
||||
ui->radioButtonWorking->setChecked(true);
|
||||
|
||||
connect(ui->comboBoxFilters, SIGNAL(activated(int)), this, SLOT(updateTableWidget(int)));
|
||||
connect(ui->comboBoxSort, SIGNAL(activated(int)), this, SLOT(changeSortOrder()));
|
||||
connect(ui->tableWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateListWidget()));
|
||||
connect(ui->listWidgetProjects, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showItemInfo(QListWidgetItem*)));
|
||||
connect(ui->pushButtonBack, SIGNAL(clicked()), this, SLOT(pushButtonBackClicked()));
|
||||
connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(pushButtonClearClicked()));
|
||||
connect(searchEdit, SIGNAL(returnPressed()), this, SLOT(pushButtonSearchClicked()));
|
||||
connect(searchButton, SIGNAL(clicked()), this, SLOT(pushButtonSearchClicked()));
|
||||
connect(ui->pushButtonApplyFilters, SIGNAL(clicked()), this, SLOT(pushButtonApplyFiltersClicked()));
|
||||
connect(ui->pushButtonCanselFilters, SIGNAL(clicked()), this, SLOT(pushButtonCancelFiltersClicked()));
|
||||
connect(ui->pushButtonDefault, SIGNAL(clicked()), this, SLOT(pushButtonDefaultClicked()));
|
||||
|
||||
QFile styleFile(":/styles.qss");
|
||||
if (styleFile.open(QFile::ReadOnly)) {
|
||||
QTextStream ts(&styleFile);
|
||||
QString style = ts.readAll();
|
||||
qApp->setStyleSheet(style);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::getStages(QMap<int, Stages> &map)
|
||||
{
|
||||
mapStages = map;
|
||||
}
|
||||
|
||||
void MainWindow::getTeams(QMap<int, Team> &map)
|
||||
{
|
||||
mapTeams = map;
|
||||
}
|
||||
|
||||
void MainWindow::getWorkers(QMap<int, Worker> &map)
|
||||
{
|
||||
mapWorkers = map;
|
||||
}
|
||||
|
||||
void MainWindow::getDeviceTypes(QMap<int, DeviceType> &map)
|
||||
{
|
||||
mapDeviceTypes = map;
|
||||
for (int i = 1; i <= mapDeviceTypes.size(); i++) {
|
||||
QString imagePath = QString(":/images/device-type-%1.png").arg(i);
|
||||
deviceTypeImages[i] = imagePath;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::getDeviceModels(QMap<int, DeviceModel> &map)
|
||||
{
|
||||
mapDeviceModels = map;
|
||||
}
|
||||
|
||||
void MainWindow::getProjects(QMap<int, Project> &map)
|
||||
{
|
||||
mapDevices = map;
|
||||
updateTableWidget(0);
|
||||
}
|
||||
|
||||
void MainWindow::updateTableWidget(int index)
|
||||
{
|
||||
returnToDeviceList();
|
||||
|
||||
ui->tableWidget->clearContents();
|
||||
ui->tableWidget->setRowCount(0);
|
||||
|
||||
switch (index) {
|
||||
case 0: // Все устройства
|
||||
clearDevicesOutputSettings();
|
||||
updateListWidgetDevices(0);
|
||||
break;
|
||||
case 1: // Типы устройств
|
||||
fillTable<DeviceType>(mapDeviceTypes);
|
||||
break;
|
||||
case 2: // Этапы
|
||||
fillTable<Stages>(mapStages);
|
||||
break;
|
||||
case 3: // Команды
|
||||
fillTable<Team>(mapTeams);
|
||||
break;
|
||||
case 4: // Работники
|
||||
fillTable<Worker>(mapWorkers);
|
||||
break;
|
||||
case 5: // Модели проектов
|
||||
fillTable<DeviceModel>(mapDeviceModels);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateListWidget()
|
||||
{
|
||||
returnToDeviceList();
|
||||
|
||||
int selectedEntityId = getSelectedIndex();
|
||||
|
||||
if (selectedEntityId == -1)
|
||||
return;
|
||||
|
||||
clearDevicesOutputSettings();
|
||||
updateListWidgetDevices(selectedEntityId);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void MainWindow::fillTable(const QMap<int, T> &map)
|
||||
{
|
||||
int row = 0;
|
||||
for (auto &item : map) {
|
||||
ui->tableWidget->insertRow(row);
|
||||
|
||||
QTableWidgetItem *idItem = new QTableWidgetItem(QString::number(item.id()));
|
||||
QTableWidgetItem *nameItem = new QTableWidgetItem(item.name());
|
||||
|
||||
idItem->setFlags(idItem->flags() & ~Qt::ItemIsEditable);
|
||||
nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
|
||||
|
||||
ui->tableWidget->setItem(row, 0, idItem);
|
||||
ui->tableWidget->setItem(row, 1, nameItem);
|
||||
|
||||
idItem->setTextAlignment(Qt::AlignCenter);
|
||||
nameItem->setTextAlignment(Qt::AlignCenter);
|
||||
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateListWidgetDevices(int entityId)
|
||||
{
|
||||
ui->listWidgetProjects->clear();
|
||||
|
||||
auto filteredDevices = logic->findDevicesByAllParameters(
|
||||
mapDevices,
|
||||
entityId,
|
||||
ui->comboBoxFilters->currentIndex(),
|
||||
searchInfo,
|
||||
filterParams,
|
||||
ui->comboBoxSort->currentText()
|
||||
);
|
||||
|
||||
if (filteredDevices.isEmpty()) {
|
||||
QListWidgetItem *item = new QListWidgetItem(ui->listWidgetProjects);
|
||||
ui->listWidgetProjects->addItem(item);
|
||||
QWidget *cardWidget = createMessageEmptyCard();
|
||||
item->setSizeHint(cardWidget->minimumSizeHint());
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
|
||||
ui->listWidgetProjects->setItemWidget(item, cardWidget);
|
||||
} else {
|
||||
for (auto &device : filteredDevices) {
|
||||
addDeviceToList(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *MainWindow::createMessageEmptyCard()
|
||||
{
|
||||
QWidget *cardWidget = new QWidget(ui->listWidgetProjects);
|
||||
QVBoxLayout *cardLayout = new QVBoxLayout(cardWidget);
|
||||
|
||||
QLabel *titleLabel = new QLabel("По заданным параметрам ничего не найдено", cardWidget);
|
||||
QFont titleFont("Arial", 17, QFont::Bold);
|
||||
titleLabel->setFont(titleFont);
|
||||
|
||||
cardLayout->addWidget(titleLabel, 0, Qt::AlignCenter);
|
||||
|
||||
cardLayout->setSpacing(12);
|
||||
|
||||
QLabel *imageLabel = new QLabel(cardWidget);
|
||||
QPixmap pixmap(":/images/question.png");
|
||||
imageLabel->setPixmap(pixmap.scaled(256, 256, Qt::KeepAspectRatio));
|
||||
|
||||
cardLayout->addWidget(imageLabel, 0, Qt::AlignCenter);
|
||||
|
||||
return cardWidget;
|
||||
}
|
||||
|
||||
QWidget *MainWindow::createDeviceCard(const Project &project)
|
||||
{
|
||||
QWidget *cardWidget = new QWidget(ui->listWidgetProjects);
|
||||
QVBoxLayout *cardLayout = new QVBoxLayout(cardWidget);
|
||||
|
||||
QFrame *topBorder = new QFrame(cardWidget);
|
||||
topBorder->setFrameShape(QFrame::HLine);
|
||||
topBorder->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
cardLayout->addWidget(topBorder);
|
||||
|
||||
QHBoxLayout *iconTextlayout = new QHBoxLayout();
|
||||
|
||||
QLabel *imageLabel = new QLabel(cardWidget);
|
||||
QString imagePath = deviceTypeImages[project.deviceModel().idType()];
|
||||
QPixmap pixmap(imagePath);
|
||||
imageLabel->setPixmap(pixmap.scaled(100, 100, Qt::KeepAspectRatio));
|
||||
|
||||
iconTextlayout->addWidget(imageLabel);
|
||||
|
||||
QVBoxLayout *textLayout = new QVBoxLayout();
|
||||
|
||||
QLabel *serialNumberLabel = new QLabel(project.name(), cardWidget);
|
||||
QFont serialNumberFont("Arial", 14, QFont::Bold);
|
||||
serialNumberLabel->setFont(serialNumberFont);
|
||||
textLayout->addWidget(serialNumberLabel);
|
||||
|
||||
QFont generalFont("Arial", 11);
|
||||
|
||||
QString typeName = project.deviceModel().nameType();
|
||||
typeName = typeName.left(typeName.length());
|
||||
if (typeName == "Персональные компьютер")
|
||||
typeName = "Персональный компьютер";
|
||||
QLabel *typeNameLabel = new QLabel(typeName + ": " + project.deviceModel().name(), cardWidget);
|
||||
typeNameLabel->setFont(generalFont);
|
||||
textLayout->addWidget(typeNameLabel);
|
||||
|
||||
QLabel *statusLabel = new QLabel(project.isReady() ? "Готов" : "Не готов", cardWidget);
|
||||
statusLabel->setFont(generalFont);
|
||||
textLayout->addWidget(statusLabel);
|
||||
|
||||
QHBoxLayout *priceLikeLayout = new QHBoxLayout();
|
||||
priceLikeLayout->setSpacing(100);
|
||||
|
||||
QLabel *priceLabel = new QLabel(QString::number(project.budget()) + " ₽", cardWidget);
|
||||
priceLabel->setFont(generalFont);
|
||||
priceLabel->setFixedWidth(100);
|
||||
priceLikeLayout->addWidget(priceLabel);
|
||||
|
||||
priceLikeLayout->addSpacerItem(new QSpacerItem(40, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
QCheckBox *likeCheckBox = new QCheckBox("Нравится", cardWidget);
|
||||
likeCheckBox->setChecked(project.isLiked());
|
||||
likeCheckBox->setFont(generalFont);
|
||||
likeCheckBox->setStyleSheet(likeCheckBox->isChecked() ? "color: green;" : "color: black;");
|
||||
|
||||
connect(likeCheckBox, &QCheckBox::toggled, this, [this, project, likeCheckBox](bool checked) {
|
||||
Project& deviceRef = mapDevices[project.id()];
|
||||
deviceRef.setIsLiked(checked);
|
||||
|
||||
QString message = checked ? "Проект добавлен в избранное." : "Проект удален из избранного.";
|
||||
QMessageBox::information(this, "Обновление", message);
|
||||
|
||||
likeCheckBox->setStyleSheet(checked ? "color: green;" : "color: black;");
|
||||
});
|
||||
|
||||
priceLikeLayout->addWidget(likeCheckBox);
|
||||
|
||||
textLayout->addLayout(priceLikeLayout);
|
||||
|
||||
iconTextlayout->addSpacerItem(new QSpacerItem(40, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
iconTextlayout->addLayout(textLayout);
|
||||
|
||||
cardLayout->addLayout(iconTextlayout);
|
||||
|
||||
QFrame *bottomBorder = new QFrame(cardWidget);
|
||||
bottomBorder->setFrameShape(QFrame::HLine);
|
||||
bottomBorder->setFrameShadow(QFrame::Sunken);
|
||||
cardLayout->addWidget(bottomBorder);
|
||||
|
||||
cardLayout->setContentsMargins(2, 0, 2, 0);
|
||||
|
||||
return cardWidget;
|
||||
}
|
||||
|
||||
void MainWindow::addDeviceToList(const Project &device)
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem(ui->listWidgetProjects);
|
||||
ui->listWidgetProjects->addItem(item);
|
||||
|
||||
QWidget *cardWidget = createDeviceCard(device);
|
||||
|
||||
item->setSizeHint(cardWidget->minimumSizeHint());
|
||||
ui->listWidgetProjects->setItemWidget(item, cardWidget);
|
||||
|
||||
item->setData(Qt::UserRole, device.id());
|
||||
}
|
||||
|
||||
void MainWindow::returnToDeviceList()
|
||||
{
|
||||
idCard = 0;
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void MainWindow::showItemInfo(QListWidgetItem *item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
int deviceId = item->data(Qt::UserRole).toInt();
|
||||
Project device = mapDevices[deviceId];
|
||||
|
||||
idCard = deviceId;
|
||||
if (!device.StartProjectDate().isValid())
|
||||
qDebug() << "StartProjectDate is invalid for device ID:" << device.id();
|
||||
if (!device.FinishProjectDate().isValid())
|
||||
qDebug() << "FinishProjectDate is invalid for device ID:" << device.id();
|
||||
ui->lineEditId->setText(QString::number(device.id()));
|
||||
ui->lineEditSerialNum->setText(device.name());
|
||||
ui->lineEditPrice->setText(QString::number(device.budget(), 'f', 2));
|
||||
ui->lineEditEmployee->setText(device.nameTeam());
|
||||
ui->lineEditModel->setText(device.deviceModel().name());
|
||||
ui->lineEditType->setText(device.deviceModel().nameType());
|
||||
ui->textEditFurtherInformation->setPlainText(device.description());
|
||||
ui->checkBoxIsWorking->setChecked(device.isReady());
|
||||
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void MainWindow::clearFilters()
|
||||
{
|
||||
ui->radioButtonWorking->setChecked(true);
|
||||
ui->doubleSpinBoxFrom->setValue(0.00);
|
||||
ui->doubleSpinBoxTo->setValue(0.00);
|
||||
filterParams.setIsReady(true);
|
||||
filterParams.setPriceFrom(-1);
|
||||
filterParams.setPriceTo(-1);
|
||||
filterParams.setDisregardState(false);
|
||||
filterParams.setApllyFilters(false);
|
||||
}
|
||||
|
||||
void MainWindow::clearDevicesOutputSettings()
|
||||
{
|
||||
ui->comboBoxSort->setCurrentIndex(0);
|
||||
|
||||
ui->lineEditSearch->setText("");
|
||||
searchInfo = "";
|
||||
|
||||
clearFilters();
|
||||
}
|
||||
|
||||
int MainWindow::getSelectedIndex()
|
||||
{
|
||||
QModelIndexList selectedIndexes = ui->tableWidget->selectionModel()->selectedRows();
|
||||
|
||||
if (selectedIndexes.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rowIndex = selectedIndexes.first().row();
|
||||
|
||||
return ui->tableWidget->item(rowIndex, 0)->text().toInt();
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonBackClicked()
|
||||
{
|
||||
returnToDeviceList();
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonClearClicked()
|
||||
{
|
||||
ui->lineEditSearch->setText("");
|
||||
}
|
||||
|
||||
void MainWindow::changeSortOrder()
|
||||
{
|
||||
updateListWidgetDevices(getSelectedIndex());
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonSearchClicked()
|
||||
{
|
||||
searchInfo = ui->lineEditSearch->text();
|
||||
if (searchInfo.isEmpty()) {
|
||||
QMessageBox::warning(this, "Ошибка", "Пожалуйста, введите текст для поиска.");
|
||||
return;
|
||||
}
|
||||
ui->comboBoxSort->setCurrentIndex(0);
|
||||
clearFilters();
|
||||
updateListWidgetDevices(getSelectedIndex());
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonApplyFiltersClicked()
|
||||
{
|
||||
double priceFrom = ui->doubleSpinBoxFrom->value();
|
||||
double priceTo = ui->doubleSpinBoxTo->value();
|
||||
if (priceFrom > priceTo) {
|
||||
QMessageBox::warning(this, "Ошибка", "Начальное значение диапазона не может быть больше конечного значения.");
|
||||
|
||||
ui->doubleSpinBoxFrom->setValue(filterParams.priceFrom());
|
||||
ui->doubleSpinBoxTo->setValue(filterParams.priceTo());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
filterParams.setApllyFilters(true);
|
||||
filterParams.setDisregardState(ui->radioButtonDisregard->isChecked());
|
||||
filterParams.setIsReady(ui->radioButtonWorking->isChecked());
|
||||
|
||||
if (priceFrom == 0.00 && priceTo == 0.00) {
|
||||
filterParams.setPriceFrom(0.00);
|
||||
filterParams.setPriceTo(std::numeric_limits<double>::max());
|
||||
} else {
|
||||
filterParams.setPriceFrom(priceFrom);
|
||||
filterParams.setPriceTo(priceTo);
|
||||
}
|
||||
|
||||
updateListWidgetDevices(getSelectedIndex());
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonCancelFiltersClicked()
|
||||
{
|
||||
clearFilters();
|
||||
updateListWidgetDevices(getSelectedIndex());
|
||||
}
|
||||
|
||||
void MainWindow::pushButtonDefaultClicked()
|
||||
{
|
||||
clearDevicesOutputSettings();
|
||||
updateListWidgetDevices(getSelectedIndex());
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
ServiceLoadDB serviceLoadDB;
|
||||
serviceLoadDB.updateLikesState(mapDevices);
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
88
mainwindow.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QCloseEvent>
|
||||
#include <QDialog>
|
||||
#include <QButtonGroup>
|
||||
#include <QScreen>
|
||||
#include <QListWidget>
|
||||
#include <QToolTip>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QTextStream>
|
||||
#include <service/serviceloaddb.h>
|
||||
#include <service/projectlogic.h>
|
||||
#include <service/filterparams.h>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
void fillTable(const QMap<int, T> &map);
|
||||
void updateListWidgetDevices(int entityId);
|
||||
QWidget* createMessageEmptyCard();
|
||||
QWidget* createDeviceCard(const Project &project);
|
||||
void addDeviceToList(const Project &project);
|
||||
void returnToDeviceList();
|
||||
void showTableWithStructureElements(const QList<DeviceStructureElement>& elements);
|
||||
void showTableWithDeviceModelCharacteristics(const DeviceModel& model);
|
||||
void clearFilters();
|
||||
void clearDevicesOutputSettings();
|
||||
int getSelectedIndex();
|
||||
|
||||
|
||||
public slots:
|
||||
void getStages(QMap<int, Stages> &map);
|
||||
void getTeams(QMap<int, Team> &map);
|
||||
void getWorkers(QMap<int, Worker> &map);
|
||||
void getDeviceTypes(QMap<int, DeviceType> &map);
|
||||
void getDeviceModels(QMap<int, DeviceModel> &map);
|
||||
void getProjects(QMap<int, Project> &map);
|
||||
|
||||
private slots:
|
||||
void updateTableWidget(int index);
|
||||
void updateListWidget();
|
||||
void showItemInfo(QListWidgetItem*);
|
||||
void changeSortOrder();
|
||||
void pushButtonBackClicked();
|
||||
void pushButtonClearClicked();
|
||||
void pushButtonSearchClicked();
|
||||
void pushButtonApplyFiltersClicked();
|
||||
void pushButtonCancelFiltersClicked();
|
||||
void pushButtonStructureClicked();
|
||||
void pushButtonCharacteristicsClicked();
|
||||
void pushButtonDefaultClicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
ProjectLogic *logic;
|
||||
|
||||
QString searchInfo = "";
|
||||
FilterParams filterParams;
|
||||
|
||||
int idCard = 0;
|
||||
|
||||
QMap<int, QString> deviceTypeImages;
|
||||
|
||||
QMap<int, Stages> mapStages;
|
||||
QMap<int, Worker> mapWorkers;
|
||||
QMap<int, Team> mapTeams;
|
||||
QMap<int, DeviceType> mapDeviceTypes;
|
||||
QMap<int, DeviceModel> mapDeviceModels;
|
||||
QMap<int, Project> mapDevices;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
732
mainwindow.ui
Normal file
@ -0,0 +1,732 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1147</width>
|
||||
<height>905</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Factory</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QComboBox" name="comboBoxFilters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>481</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>570</x>
|
||||
<y>0</y>
|
||||
<width>581</width>
|
||||
<height>862</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<widget class="QLabel" name="labelProjects">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>10</y>
|
||||
<width>571</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>12</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Проекты</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="listWidgetProjects">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>80</y>
|
||||
<width>571</width>
|
||||
<height>461</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBoxSort">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>42</y>
|
||||
<width>321</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditSearch">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>560</y>
|
||||
<width>451</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButtonClear">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>460</x>
|
||||
<y>560</y>
|
||||
<width>111</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Очистить</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBoxFilters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>610</y>
|
||||
<width>571</width>
|
||||
<height>252</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButtonApplyFilters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>190</y>
|
||||
<width>161</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Применить фильтрацию</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButtonCanselFilters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>190</y>
|
||||
<width>151</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Отменить фильтры</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelFilters">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>561</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>12</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Фильтры</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelWorkingState">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>751</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Состояние</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelPrice">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>110</y>
|
||||
<width>751</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Цена</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonWorking">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>89</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Готов</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonNotWorking">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>70</y>
|
||||
<width>89</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Не готов</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxFrom">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>150</y>
|
||||
<width>151</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999999.990000000223517</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxTo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>150</y>
|
||||
<width>151</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999999.990000000223517</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelFrom">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>150</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>от</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelTo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>150</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>до</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButtonDisregard">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>70</y>
|
||||
<width>141</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Не учитывать</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButtonDefault">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>40</y>
|
||||
<width>161</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Вывод по умолчанию</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<widget class="QLabel" name="labelDevice">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>10</y>
|
||||
<width>571</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>12</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Информация о проекте</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditId">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>50</y>
|
||||
<width>431</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelId">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>52</y>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Идентификатор</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditSerialNum">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>90</y>
|
||||
<width>431</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelSerialNum">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>92</y>
|
||||
<width>131</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Название проекта</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelDevicePrice">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>130</y>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Стоимость</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditPrice">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>130</y>
|
||||
<width>431</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelEmployee">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>170</y>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Отв. команда</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditEmployee">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>170</y>
|
||||
<width>431</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelModel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>210</y>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Модель</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditModel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>210</y>
|
||||
<width>431</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>250</y>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Тип</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>250</y>
|
||||
<width>431</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="textEditFurtherInformation">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>290</y>
|
||||
<width>431</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelFurtherInformation">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>300</y>
|
||||
<width>121</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Дополнительная </p><p>информация</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBoxIsWorking">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>400</y>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelWorking">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>400</y>
|
||||
<width>121</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Готов</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButtonBack">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>820</y>
|
||||
<width>101</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Назад</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>40</y>
|
||||
<width>481</width>
|
||||
<height>821</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SelectionMode::SingleSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1147</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
24
presenter.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "presenter.h"
|
||||
|
||||
Presenter::Presenter(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
DB = new ServiceLoadDB();
|
||||
window = new MainWindow();
|
||||
window->show();
|
||||
|
||||
connect(DB, &ServiceLoadDB::sendStages, window, &MainWindow::getStages);
|
||||
connect(DB, &ServiceLoadDB::sendTeams, window, &MainWindow::getTeams);
|
||||
connect(DB, &ServiceLoadDB::sendWorkers, window, &MainWindow::getWorkers);
|
||||
connect(DB, &ServiceLoadDB::sendDeviceTypes, window, &MainWindow::getDeviceTypes);
|
||||
connect(DB, &ServiceLoadDB::sendDeviceModels, window, &MainWindow::getDeviceModels);
|
||||
connect(DB, &ServiceLoadDB::sendProjects, window, &MainWindow::getProjects);
|
||||
|
||||
DB->start();
|
||||
}
|
||||
|
||||
Presenter::~Presenter()
|
||||
{
|
||||
DB->deleteLater();
|
||||
window->deleteLater();
|
||||
}
|
21
presenter.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef PRESENTER_H
|
||||
#define PRESENTER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "service/serviceloaddb.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
class Presenter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Presenter(QObject *parent = nullptr);
|
||||
~Presenter();
|
||||
|
||||
private:
|
||||
ServiceLoadDB *DB;
|
||||
MainWindow *window;
|
||||
};
|
||||
|
||||
#endif // PRESENTER_H
|
BIN
resources/images/device-type-1.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
resources/images/device-type-2.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
resources/images/device-type-3.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
resources/images/device-type-4.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
resources/images/device-type-5.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
resources/images/device-type-6.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
resources/images/device-type-7.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
resources/images/device-type-8.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
resources/images/down-arrow.png
Normal file
After Width: | Height: | Size: 310 B |
BIN
resources/images/mw-icon.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
resources/images/search.png
Normal file
After Width: | Height: | Size: 533 B |
39
resources/resources.qrc
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
<qresource>
|
||||
<file>images/mw-icon.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/search.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/down-arrow.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-1.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-2.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-3.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-4.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-5.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-6.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-7.png</file>
|
||||
</qresource>
|
||||
<qresource>
|
||||
<file>images/device-type-8.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/">
|
||||
<file>styles.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
44
resources/styles.qss
Normal file
@ -0,0 +1,44 @@
|
||||
QComboBox, QPushButton, QLineEdit, QTextEdit, QListWidget, QTableWidget, QGroupBox {
|
||||
border: 1px solid black;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
QComboBox::drop-down {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
QComboBox::down-arrow {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
image: url(:/images/down-arrow.png);
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
background-color: white;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
QPushButton:hover {
|
||||
background-color: green;
|
||||
color: white;
|
||||
}
|
||||
|
||||
QPushButton:pressed {
|
||||
background-color: green;
|
||||
border-radius: 4px;
|
||||
border-width: 2px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
QPushButton#pushButtonSearch {
|
||||
border: none;
|
||||
background: transparent;
|
||||
}
|
53
service/filterparams.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "filterparams.h"
|
||||
|
||||
FilterParams::FilterParams() {}
|
||||
|
||||
bool FilterParams::isReady() const
|
||||
{
|
||||
return _isReady;
|
||||
}
|
||||
|
||||
void FilterParams::setIsReady(bool newIsReady)
|
||||
{
|
||||
_isReady = newIsReady;
|
||||
}
|
||||
|
||||
double FilterParams::priceFrom() const
|
||||
{
|
||||
return _priceFrom;
|
||||
}
|
||||
|
||||
void FilterParams::setPriceFrom(double newPriceFrom)
|
||||
{
|
||||
_priceFrom = newPriceFrom;
|
||||
}
|
||||
|
||||
double FilterParams::priceTo() const
|
||||
{
|
||||
return _priceTo;
|
||||
}
|
||||
|
||||
void FilterParams::setPriceTo(double newPriceTo)
|
||||
{
|
||||
_priceTo = newPriceTo;
|
||||
}
|
||||
|
||||
bool FilterParams::getDisregardState() const
|
||||
{
|
||||
return disregardState;
|
||||
}
|
||||
|
||||
void FilterParams::setDisregardState(bool newDisregardState)
|
||||
{
|
||||
disregardState = newDisregardState;
|
||||
}
|
||||
|
||||
bool FilterParams::getApllyFilters() const
|
||||
{
|
||||
return apllyFilters;
|
||||
}
|
||||
|
||||
void FilterParams::setApllyFilters(bool newApllyFilters)
|
||||
{
|
||||
apllyFilters = newApllyFilters;
|
||||
}
|
32
service/filterparams.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef FILTERPARAMS_H
|
||||
#define FILTERPARAMS_H
|
||||
|
||||
class FilterParams
|
||||
{
|
||||
public:
|
||||
FilterParams();
|
||||
|
||||
bool isReady() const;
|
||||
void setIsReady(bool newIsReady);
|
||||
|
||||
double priceFrom() const;
|
||||
void setPriceFrom(double newPriceFrom);
|
||||
|
||||
double priceTo() const;
|
||||
void setPriceTo(double newPriceTo);
|
||||
|
||||
bool getDisregardState() const;
|
||||
void setDisregardState(bool newDisregardState);
|
||||
|
||||
bool getApllyFilters() const;
|
||||
void setApllyFilters(bool newApllyFilters);
|
||||
|
||||
private:
|
||||
bool _isReady = true;
|
||||
double _priceFrom = -1;
|
||||
double _priceTo = -1;
|
||||
bool disregardState = false;
|
||||
bool apllyFilters = false;
|
||||
};
|
||||
|
||||
#endif // FILTERPARAMS_H
|
126
service/projectlogic.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
#include "projectlogic.h"
|
||||
|
||||
ProjectLogic::ProjectLogic() {}
|
||||
|
||||
QList<Project> ProjectLogic::findDevicesByAllParameters(
|
||||
const QMap<int, Project> &projects,
|
||||
int entityId, int currentEntity,
|
||||
QString searchText,
|
||||
const FilterParams &filterParams,
|
||||
const QString &sortOrder
|
||||
)
|
||||
{
|
||||
auto filteredDevices = filterByEntity(projects, entityId, currentEntity);
|
||||
filteredDevices = searchDevices(filteredDevices, searchText);
|
||||
filteredDevices = applyFilters(filteredDevices, filterParams);
|
||||
return sortDevices(filteredDevices, sortOrder);
|
||||
}
|
||||
|
||||
QMap<int, Project> ProjectLogic::filterByEntity(const QMap<int, Project> &projects, int entityId, int currentEntity)
|
||||
{
|
||||
QMap<int, Project> result;
|
||||
if (entityId == -1 || currentEntity == 0)
|
||||
return projects; // "Все проекты"
|
||||
|
||||
for (auto &project : projects) {
|
||||
switch (currentEntity) {
|
||||
case 1: // Типы устройств
|
||||
if (project.deviceModel().idType() == entityId)
|
||||
result.insert(project.id(), project);
|
||||
break;
|
||||
case 2: // Команды
|
||||
if (project.idTeam() == entityId)
|
||||
result.insert(project.id(), project);
|
||||
break;
|
||||
case 3: // Работники
|
||||
if (project.stages().idWorker() == entityId)
|
||||
result.insert(project.id(), project);
|
||||
break;
|
||||
case 4: // Этапы
|
||||
if (project.stages().id() == entityId)
|
||||
result.insert(project.id(), project);
|
||||
break;
|
||||
case 5: // Модели устройств
|
||||
if (project.deviceModel().id() == entityId)
|
||||
result.insert(project.id(), project);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QMap<int, Project> ProjectLogic::searchDevices(const QMap<int, Project> &projects, const QString &searchText)
|
||||
{
|
||||
if (searchText.isEmpty())
|
||||
return projects;
|
||||
|
||||
QMap<int, Project> result;
|
||||
for (auto &project : projects) {
|
||||
if (project.deviceModel().name().contains(searchText, Qt::CaseInsensitive) ||
|
||||
project.deviceModel().nameType().contains(searchText, Qt::CaseInsensitive)) {
|
||||
result.insert(project.id(), project);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QMap<int, Project> ProjectLogic::applyFilters(const QMap<int, Project> &projects, const FilterParams &filterParams)
|
||||
{
|
||||
if (!filterParams.getApllyFilters())
|
||||
return projects;
|
||||
QMap<int, Project> result;
|
||||
if (filterParams.getDisregardState())
|
||||
{
|
||||
for (auto &project : projects) {
|
||||
if (project.budget() < filterParams.priceFrom() || project.budget() > filterParams.priceTo())
|
||||
continue;
|
||||
result.insert(project.id(), project);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto &project : projects) {
|
||||
if (project.isReady() != filterParams.isReady())
|
||||
continue;
|
||||
if (project.budget() < filterParams.priceFrom() || project.budget() > filterParams.priceTo())
|
||||
continue;
|
||||
result.insert(project.id(), project);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<Project> ProjectLogic::sortDevices(QMap<int, Project> &projects, const QString &sortOrder)
|
||||
{
|
||||
QList<Project> deviceList = projects.values();
|
||||
|
||||
if (sortOrder == "Сначала новые") {
|
||||
std::sort(deviceList.begin(), deviceList.end(), [](const Project &a, const Project &b) {
|
||||
return a.StartProjectDate() < b.StartProjectDate();
|
||||
});
|
||||
}
|
||||
if (sortOrder == "Сначала старые") {
|
||||
std::sort(deviceList.begin(), deviceList.end(), [](const Project &a, const Project &b) {
|
||||
return a.FinishProjectDate() > b.FinishProjectDate();
|
||||
});
|
||||
}
|
||||
if (sortOrder == "Сначала дешевые") {
|
||||
std::sort(deviceList.begin(), deviceList.end(), [](const Project &a, const Project &b) {
|
||||
return a.budget() < b.budget();
|
||||
});
|
||||
}
|
||||
if (sortOrder == "Сначала дорогие") {
|
||||
std::sort(deviceList.begin(), deviceList.end(), [](const Project &a, const Project &b) {
|
||||
return a.budget() > b.budget();
|
||||
});
|
||||
}
|
||||
if (sortOrder == "Сначала с лайком") {
|
||||
std::sort(deviceList.begin(), deviceList.end(), [](const Project &a, const Project &b) {
|
||||
return a.isLiked() > b.isLiked();
|
||||
});
|
||||
}
|
||||
|
||||
return deviceList;
|
||||
}
|
27
service/projectlogic.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef PROJECTLOGIC_H
|
||||
#define PROJECTLOGIC_H
|
||||
|
||||
#include "types.h"
|
||||
#include "filterparams.h"
|
||||
|
||||
class ProjectLogic
|
||||
{
|
||||
public:
|
||||
ProjectLogic();
|
||||
QList<Project> findDevicesByAllParameters(
|
||||
const QMap<int, Project> &projects,
|
||||
int entityId,
|
||||
int currentEntity,
|
||||
QString searchText,
|
||||
const FilterParams &filterParams,
|
||||
const QString &sortOrder
|
||||
);
|
||||
|
||||
private:
|
||||
QMap<int, Project> filterByEntity(const QMap<int, Project> &projects, int entityId, int currentEntity);
|
||||
QMap<int, Project> searchDevices(const QMap<int, Project> &projects, const QString &searchText);
|
||||
QMap<int, Project> applyFilters(const QMap<int, Project> &projects, const FilterParams &filterParams);
|
||||
QList<Project> sortDevices(QMap<int, Project> &devices, const QString &sortOrder);
|
||||
};
|
||||
|
||||
#endif // PROJECTLOGIC_H
|
276
service/serviceloaddb.cpp
Normal file
@ -0,0 +1,276 @@
|
||||
#include "serviceloaddb.h"
|
||||
|
||||
ServiceLoadDB::ServiceLoadDB(QObject *parent)
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
void ServiceLoadDB::start()
|
||||
{
|
||||
db = QSqlDatabase::addDatabase("QPSQL");
|
||||
db.setHostName("127.0.0.1");
|
||||
db.setDatabaseName("ProjectsAccountingDB");
|
||||
db.setUserName("postgres");
|
||||
db.setPassword("12345");
|
||||
if(!db.open()){
|
||||
qDebug() << "Не удалось открыть БД ";
|
||||
return;
|
||||
}
|
||||
query = QSqlQuery(db);
|
||||
|
||||
loadStages();
|
||||
loadWorkers();
|
||||
loadTeams();
|
||||
loadDeviceTypes();
|
||||
loadDeviceModels();
|
||||
loadProjects();
|
||||
}
|
||||
|
||||
void ServiceLoadDB::loadStages()
|
||||
{
|
||||
QFile file("../../data/requestStages.sql");
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
|
||||
db_input = QString(file.readAll());
|
||||
|
||||
if (!query.exec(db_input)) {
|
||||
qDebug() << "Ошибка запроса к таблице stages: " << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlRecord rec;
|
||||
while (query.next()) {
|
||||
rec = query.record();
|
||||
|
||||
Stages stages;
|
||||
int id = query.value(rec.indexOf("ID")).toInt();
|
||||
stages.setId(id);
|
||||
stages.setName(query.value(rec.indexOf("Name")).toString());
|
||||
stages.setStartDate(query.value(rec.indexOf("StartDate")).toDateTime());
|
||||
stages.setFinishDate(query.value(rec.indexOf("FinishDate")).toDateTime());
|
||||
stages.setCompleted(query.value(rec.indexOf("Completed")).toBool());
|
||||
stages.setExpenses(query.value(rec.indexOf("Expenses")).toDouble());
|
||||
stages.setIdWorker(query.value(rec.indexOf("WorkerID")).toInt());
|
||||
stages.setNameWorker(query.value(rec.indexOf("worker_name")).toString());
|
||||
|
||||
mapStages.insert(stages.id(), stages);
|
||||
}
|
||||
|
||||
emit sendStages(mapStages);
|
||||
}
|
||||
|
||||
void ServiceLoadDB::loadWorkers()
|
||||
{
|
||||
QFile file("../../data/requestWorkers.sql");
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
|
||||
db_input = QString(file.readAll());
|
||||
|
||||
if (!query.exec(db_input)) {
|
||||
qDebug() << "Ошибка запроса к таблице Worker: " << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlRecord rec;
|
||||
while (query.next()) {
|
||||
rec = query.record();
|
||||
|
||||
Worker worker;
|
||||
int id = query.value(rec.indexOf("ID")).toInt();
|
||||
worker.setId(id);
|
||||
worker.setName(query.value(rec.indexOf("Name")).toString());
|
||||
worker.setExperience(query.value(rec.indexOf("Experience")).toInt());
|
||||
worker.setPhoneNumber(query.value(rec.indexOf("PhoneNumber")).toString());
|
||||
worker.setTeamName(query.value(rec.indexOf("team_name")).toString());
|
||||
|
||||
mapWorkers.insert(worker.id(), worker);
|
||||
}
|
||||
|
||||
emit sendWorkers(mapWorkers);
|
||||
}
|
||||
|
||||
void ServiceLoadDB::loadTeams()
|
||||
{
|
||||
db_input = "SELECT * FROM public.Team";
|
||||
if (!query.exec(db_input)) {
|
||||
qDebug() << "Ошибка запроса к таблице Team: " << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlRecord rec;
|
||||
while (query.next()) {
|
||||
rec = query.record();
|
||||
|
||||
Team team;
|
||||
team.setId(query.value(rec.indexOf("ID")).toInt());
|
||||
team.setName(query.value(rec.indexOf("Name")).toString());
|
||||
team.setStatus(query.value(rec.indexOf("Status")).toBool());
|
||||
|
||||
mapTeams.insert(team.id(), team);
|
||||
}
|
||||
|
||||
emit sendTeams(mapTeams);
|
||||
}
|
||||
|
||||
void ServiceLoadDB::loadDeviceTypes()
|
||||
{
|
||||
db_input = "SELECT * FROM public.DeviceType";
|
||||
if (!query.exec(db_input)) {
|
||||
qDebug() << "Ошибка запроса к таблице DeviceType: " << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlRecord rec;
|
||||
while (query.next()) {
|
||||
rec = query.record();
|
||||
|
||||
DeviceType deviceType;
|
||||
deviceType.setId(query.value(rec.indexOf("ID")).toInt());
|
||||
deviceType.setName(query.value(rec.indexOf("Name")).toString());
|
||||
|
||||
mapDeviceTypes.insert(deviceType.id(), deviceType);
|
||||
}
|
||||
|
||||
emit sendDeviceTypes(mapDeviceTypes);
|
||||
}
|
||||
|
||||
void ServiceLoadDB::loadDeviceModels()
|
||||
{
|
||||
QFile file("../../data/requestDeviceModels.sql");
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
|
||||
db_input = QString(file.readAll());
|
||||
|
||||
if (!query.exec(db_input)) {
|
||||
qDebug() << "Ошибка запроса при получении информации о моделях проектов: " << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlRecord rec;
|
||||
while (query.next()) {
|
||||
rec = query.record();
|
||||
|
||||
DeviceModel deviceModel;
|
||||
int id = query.value(rec.indexOf("ID")).toInt();
|
||||
deviceModel.setId(id);
|
||||
deviceModel.setName(query.value(rec.indexOf("Name")).toString());
|
||||
deviceModel.setDescription(query.value(rec.indexOf("Description")).toString());
|
||||
deviceModel.setWorkEfficiency(query.value(rec.indexOf("WorkEfficiency")).toInt());
|
||||
deviceModel.setReliability(query.value(rec.indexOf("reliability")).toInt());
|
||||
deviceModel.setDurability(query.value(rec.indexOf("durability")).toInt());
|
||||
deviceModel.setCreateDate(query.value(rec.indexOf("CreateDate")).toDateTime());
|
||||
deviceModel.setStructureElements(readStructureElements(id));
|
||||
deviceModel.setIdType(query.value(rec.indexOf("DeviceTypeID")).toInt());
|
||||
deviceModel.setNameType(query.value(rec.indexOf("device_type_name")).toString());
|
||||
|
||||
mapDeviceModels.insert(deviceModel.id(), deviceModel);
|
||||
}
|
||||
|
||||
emit sendDeviceModels(mapDeviceModels);
|
||||
}
|
||||
|
||||
void ServiceLoadDB::loadProjects()
|
||||
{
|
||||
QFile file("../../data/requestProjects.sql");
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
db_input = QString(file.readAll());
|
||||
|
||||
if (!query.exec(db_input)) {
|
||||
qDebug() << "Ошибка запроса при получении информации о проектах: " << query.lastError().text();
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlRecord rec;
|
||||
while (query.next()) {
|
||||
rec = query.record();
|
||||
|
||||
Project project;
|
||||
int id = query.value(rec.indexOf("id")).toInt();
|
||||
int idModel = query.value(rec.indexOf("ModelID")).toInt();
|
||||
if (!mapDeviceModels.contains(idModel)) {
|
||||
qDebug() << "Не загружена модель проекта. Идентификатор проекта: " << id;
|
||||
return;
|
||||
}
|
||||
|
||||
project.setId(id);
|
||||
project.setName(query.value(rec.indexOf("Name")).toString());
|
||||
project.setDescription(query.value(rec.indexOf("Description")).toString());
|
||||
project.setStartProjectDate(query.value(rec.indexOf("StartProjectDate")).toDateTime());
|
||||
project.setFinishProjectDate(query.value(rec.indexOf("FinishProjectDate")).toDateTime());
|
||||
project.setBudget(query.value(rec.indexOf("Budget")).toDouble());
|
||||
project.setIsReady(query.value(rec.indexOf("isReady")).toBool());
|
||||
project.setIdTeam(query.value(rec.indexOf("TeamID")).toInt());
|
||||
project.setNameTeam(query.value(rec.indexOf("team_name")).toString());
|
||||
project.setIdStages(query.value(rec.indexOf("StagesID")).toInt());
|
||||
project.setNameStages(query.value(rec.indexOf("stages_name")).toString());
|
||||
project.setDeviceModel(mapDeviceModels[idModel]);
|
||||
project.setIsLiked(query.value(rec.indexOf("isLiked")).toBool());
|
||||
|
||||
mapProjects.insert(project.id(), project);
|
||||
}
|
||||
|
||||
emit sendProjects(mapProjects);
|
||||
}
|
||||
|
||||
void ServiceLoadDB::updateLikesState(QMap<int, Project> &map)
|
||||
{
|
||||
if (map.isEmpty()) {
|
||||
qDebug() << "Нет проектов для обновления";
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList updateQueries;
|
||||
for (auto &project : map) {
|
||||
int id = project.id();
|
||||
bool isLiked = project.isLiked();
|
||||
|
||||
updateQueries << QString("WHEN %1 THEN %2").arg(id).arg(isLiked ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
QString caseQuery = updateQueries.join(" ");
|
||||
|
||||
QStringList idStrings;
|
||||
QList<int> keys = map.keys();
|
||||
for (int id : keys) {
|
||||
idStrings << QString::number(id);
|
||||
}
|
||||
|
||||
db_input = QString("UPDATE Project SET isLiked = CASE id %1 END WHERE id IN (%2)")
|
||||
.arg(caseQuery, idStrings.join(", "));
|
||||
|
||||
if (!query.exec(db_input)) {
|
||||
qDebug() << "Ошибка обновления состояния isLiked у проектов: " << query.lastError().text();
|
||||
}
|
||||
}
|
||||
|
||||
QList<DeviceStructureElement> ServiceLoadDB::readStructureElements(int modelId)
|
||||
{
|
||||
QSqlQuery secondQuery;
|
||||
db_input = "SELECT * FROM get_model_structure(:model_id)";
|
||||
secondQuery.prepare(db_input);
|
||||
secondQuery.bindValue(":model_id", modelId);
|
||||
if (!secondQuery.exec()) {
|
||||
qDebug() << "Ошибка при выполнении запроса для получения элементов структуры: " << secondQuery.lastError().text();
|
||||
return QList<DeviceStructureElement>();
|
||||
}
|
||||
|
||||
QSqlRecord rec;
|
||||
QList<DeviceStructureElement> elements;
|
||||
while (secondQuery.next()) {
|
||||
rec = secondQuery.record();
|
||||
|
||||
DeviceStructureElement element;
|
||||
element.setId(secondQuery.value(rec.indexOf("Идентификатор элемента")).toInt());
|
||||
element.setName(secondQuery.value(rec.indexOf("Модель")).toString());
|
||||
element.setDescription(secondQuery.value(rec.indexOf("Описание элемента")).toString());
|
||||
element.setNameType(secondQuery.value(rec.indexOf("Тип элемента")).toString());
|
||||
element.setCount(secondQuery.value(rec.indexOf("Количество")).toInt());
|
||||
|
||||
elements.append(element);
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
60
service/serviceloaddb.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef SERVICELOADDB_H
|
||||
#define SERVICELOADDB_H
|
||||
|
||||
#include "service/types.h"
|
||||
#include <QObject>
|
||||
#include <QMessageBox>
|
||||
#include <QSql>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlRecord>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QFile>
|
||||
|
||||
class ServiceLoadDB : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ServiceLoadDB(QObject *parent = nullptr);
|
||||
void start();
|
||||
void updateLikesState(QMap<int, Project> &);
|
||||
|
||||
private:
|
||||
QList<DeviceStructureElement> readStructureElements(int modelId);
|
||||
|
||||
signals:
|
||||
void sendStages(QMap<int, Stages> &);
|
||||
void sendWorkers(QMap<int, Worker> &);
|
||||
void sendTeams(QMap<int, Team> &);
|
||||
void sendDeviceTypes(QMap<int, DeviceType> &);
|
||||
void sendDeviceModels(QMap<int, DeviceModel> &);
|
||||
void sendProjects(QMap<int, Project> &);
|
||||
|
||||
public slots:
|
||||
void loadStages();
|
||||
void loadWorkers();
|
||||
void loadTeams();
|
||||
void loadDeviceTypes();
|
||||
void loadDeviceModels();
|
||||
void loadProjects();
|
||||
|
||||
private:
|
||||
QSqlDatabase db;
|
||||
QString db_input;
|
||||
QSqlQuery query;
|
||||
|
||||
QMap<int, Stages> mapStages;
|
||||
QMap<int, Worker> mapWorkers;
|
||||
QMap<int, Team> mapTeams;
|
||||
QMap<int, DeviceType> mapDeviceTypes;
|
||||
QMap<int, DeviceModel> mapDeviceModels;
|
||||
QMap<int, Project> mapProjects;
|
||||
signals:
|
||||
};
|
||||
|
||||
#endif // SERVICELOADDB_H
|
487
service/types.cpp
Normal file
@ -0,0 +1,487 @@
|
||||
#include "types.h"
|
||||
|
||||
Types::Types() {}
|
||||
|
||||
Worker::Worker() {}
|
||||
|
||||
int Worker::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void Worker::setId(int newId)
|
||||
{
|
||||
_id = newId;
|
||||
}
|
||||
|
||||
QString Worker::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void Worker::setName(const QString &newName)
|
||||
{
|
||||
_name = newName;
|
||||
}
|
||||
|
||||
int Worker::experience() const
|
||||
{
|
||||
return _experience;
|
||||
}
|
||||
|
||||
void Worker::setExperience(int newExperience)
|
||||
{
|
||||
_experience = newExperience;
|
||||
}
|
||||
|
||||
QString Worker::phoneNumber() const
|
||||
{
|
||||
return _phoneNumber;
|
||||
}
|
||||
|
||||
void Worker::setPhoneNumber(const QString &newPhoneNumber)
|
||||
{
|
||||
_phoneNumber = newPhoneNumber;
|
||||
}
|
||||
|
||||
QString Worker::teamName() const
|
||||
{
|
||||
return _teamName;
|
||||
}
|
||||
|
||||
void Worker::setTeamName(const QString &newTeamName)
|
||||
{
|
||||
_teamName = newTeamName;
|
||||
}
|
||||
|
||||
Team::Team() {}
|
||||
|
||||
int Team::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void Team::setId(int newId)
|
||||
{
|
||||
_id = newId;
|
||||
}
|
||||
|
||||
bool Team::status() const
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
void Team::setStatus(bool newStatus)
|
||||
{
|
||||
_status = newStatus;
|
||||
}
|
||||
|
||||
QString Team::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void Team::setName(const QString &newName)
|
||||
{
|
||||
_name = newName;
|
||||
}
|
||||
|
||||
Stages::Stages() {}
|
||||
|
||||
int Stages::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void Stages::setId(int newId)
|
||||
{
|
||||
_id = newId;
|
||||
}
|
||||
|
||||
QString Stages::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void Stages::setName(const QString &newName)
|
||||
{
|
||||
_name = newName;
|
||||
}
|
||||
|
||||
QDateTime Stages::StartDate() const
|
||||
{
|
||||
return _StartDate;
|
||||
}
|
||||
|
||||
void Stages::setStartDate(const QDateTime &newStartDate)
|
||||
{
|
||||
_StartDate = newStartDate;
|
||||
}
|
||||
|
||||
QDateTime Stages::FinishDate() const
|
||||
{
|
||||
return _FinishDate;
|
||||
}
|
||||
|
||||
void Stages::setFinishDate(const QDateTime &newFinishDate)
|
||||
{
|
||||
_FinishDate = newFinishDate;
|
||||
}
|
||||
|
||||
int Stages::expenses() const
|
||||
{
|
||||
return _expenses;
|
||||
}
|
||||
|
||||
void Stages::setExpenses(int newExpenses)
|
||||
{
|
||||
_expenses = newExpenses;
|
||||
}
|
||||
|
||||
QString Stages::nameWorker() const
|
||||
{
|
||||
return _nameWorker;
|
||||
}
|
||||
|
||||
void Stages::setNameWorker(const QString &newNameWorker)
|
||||
{
|
||||
_nameWorker = newNameWorker;
|
||||
}
|
||||
|
||||
int Stages::idWorker() const
|
||||
{
|
||||
return _idWorker;
|
||||
}
|
||||
|
||||
void Stages::setIdWorker(int newIdWorker)
|
||||
{
|
||||
_idWorker = newIdWorker;
|
||||
}
|
||||
|
||||
bool Stages::completed() const
|
||||
{
|
||||
return _completed;
|
||||
}
|
||||
|
||||
void Stages::setCompleted(bool newCompleted)
|
||||
{
|
||||
_completed = newCompleted;
|
||||
}
|
||||
|
||||
DeviceStructureElement::DeviceStructureElement() {}
|
||||
|
||||
int DeviceStructureElement::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void DeviceStructureElement::setId(int newId)
|
||||
{
|
||||
_id = newId;
|
||||
}
|
||||
|
||||
QString DeviceStructureElement::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DeviceStructureElement::setName(const QString &newName)
|
||||
{
|
||||
_name = newName;
|
||||
}
|
||||
|
||||
QString DeviceStructureElement::description() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void DeviceStructureElement::setDescription(const QString &newDescription)
|
||||
{
|
||||
_description = newDescription;
|
||||
}
|
||||
|
||||
int DeviceStructureElement::count() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
void DeviceStructureElement::setCount(int newCount)
|
||||
{
|
||||
_count = newCount;
|
||||
}
|
||||
|
||||
QString DeviceStructureElement::nameType() const
|
||||
{
|
||||
return _nameType;
|
||||
}
|
||||
|
||||
void DeviceStructureElement::setNameType(const QString &newNameType)
|
||||
{
|
||||
_nameType = newNameType;
|
||||
}
|
||||
|
||||
DeviceModel::DeviceModel() {}
|
||||
|
||||
int DeviceModel::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void DeviceModel::setId(int newId)
|
||||
{
|
||||
_id = newId;
|
||||
}
|
||||
|
||||
QString DeviceModel::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DeviceModel::setName(const QString &newName)
|
||||
{
|
||||
_name = newName;
|
||||
}
|
||||
|
||||
QString DeviceModel::description() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void DeviceModel::setDescription(const QString &newDescription)
|
||||
{
|
||||
_description = newDescription;
|
||||
}
|
||||
|
||||
int DeviceModel::workEfficiency() const
|
||||
{
|
||||
return _workEfficiency;
|
||||
}
|
||||
|
||||
void DeviceModel::setWorkEfficiency(int newWorkEfficiency)
|
||||
{
|
||||
_workEfficiency = newWorkEfficiency;
|
||||
}
|
||||
|
||||
int DeviceModel::reliability() const
|
||||
{
|
||||
return _reliability;
|
||||
}
|
||||
|
||||
void DeviceModel::setReliability(int newReliability)
|
||||
{
|
||||
_reliability = newReliability;
|
||||
}
|
||||
|
||||
int DeviceModel::durability() const
|
||||
{
|
||||
return _durability;
|
||||
}
|
||||
|
||||
void DeviceModel::setDurability(int newDurability)
|
||||
{
|
||||
_durability = newDurability;
|
||||
}
|
||||
|
||||
QDateTime DeviceModel::CreateDate() const
|
||||
{
|
||||
return _CreateDate;
|
||||
}
|
||||
|
||||
void DeviceModel::setCreateDate(const QDateTime &newCreateDate)
|
||||
{
|
||||
_CreateDate = newCreateDate;
|
||||
}
|
||||
|
||||
QList<DeviceStructureElement> DeviceModel::structureElements() const
|
||||
{
|
||||
return _structureElements;
|
||||
}
|
||||
|
||||
void DeviceModel::setStructureElements(const QList<DeviceStructureElement> &newStructureElements)
|
||||
{
|
||||
_structureElements = newStructureElements;
|
||||
}
|
||||
|
||||
int DeviceModel::idType() const
|
||||
{
|
||||
return _idType;
|
||||
}
|
||||
|
||||
void DeviceModel::setIdType(int newIdType)
|
||||
{
|
||||
_idType = newIdType;
|
||||
}
|
||||
|
||||
QString DeviceModel::nameType() const
|
||||
{
|
||||
return _nameType;
|
||||
}
|
||||
|
||||
void DeviceModel::setNameType(const QString &newNameType)
|
||||
{
|
||||
_nameType = newNameType;
|
||||
}
|
||||
|
||||
Project::Project() {}
|
||||
|
||||
int Project::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void Project::setId(int newId)
|
||||
{
|
||||
_id = newId;
|
||||
}
|
||||
|
||||
QString Project::description() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
void Project::setDescription(const QString &newDescription)
|
||||
{
|
||||
_description = newDescription;
|
||||
}
|
||||
|
||||
QDateTime Project::StartProjectDate() const
|
||||
{
|
||||
return _StartProjectDate;
|
||||
}
|
||||
|
||||
void Project::setStartProjectDate(const QDateTime &newStartProjectDate)
|
||||
{
|
||||
_StartProjectDate = newStartProjectDate;
|
||||
}
|
||||
|
||||
QDateTime Project::FinishProjectDate() const
|
||||
{
|
||||
return _FinishProjectDate;
|
||||
}
|
||||
|
||||
void Project::setFinishProjectDate(const QDateTime &newFinishProjectDate)
|
||||
{
|
||||
_FinishProjectDate = newFinishProjectDate;
|
||||
}
|
||||
|
||||
double Project::budget() const
|
||||
{
|
||||
return _budget;
|
||||
}
|
||||
|
||||
void Project::setBudget(double newBudget)
|
||||
{
|
||||
_budget = newBudget;
|
||||
}
|
||||
|
||||
int Project::idStages() const
|
||||
{
|
||||
return _idStages;
|
||||
}
|
||||
|
||||
void Project::setIdStages(int newIdStages)
|
||||
{
|
||||
_idStages = newIdStages;
|
||||
}
|
||||
|
||||
QString Project::nameStages() const
|
||||
{
|
||||
return _nameStages;
|
||||
}
|
||||
|
||||
void Project::setNameStages(const QString &newNameStages)
|
||||
{
|
||||
_nameStages = newNameStages;
|
||||
}
|
||||
|
||||
int Project::idTeam() const
|
||||
{
|
||||
return _idTeam;
|
||||
}
|
||||
|
||||
void Project::setIdTeam(int newIdTeam)
|
||||
{
|
||||
_idTeam = newIdTeam;
|
||||
}
|
||||
|
||||
QString Project::nameTeam() const
|
||||
{
|
||||
return _nameTeam;
|
||||
}
|
||||
|
||||
void Project::setNameTeam(const QString &newNameTeam)
|
||||
{
|
||||
_nameTeam = newNameTeam;
|
||||
}
|
||||
|
||||
DeviceModel Project::deviceModel() const
|
||||
{
|
||||
return _deviceModel;
|
||||
}
|
||||
|
||||
void Project::setDeviceModel(const DeviceModel &newDeviceModel)
|
||||
{
|
||||
_deviceModel = newDeviceModel;
|
||||
}
|
||||
|
||||
bool Project::isLiked() const
|
||||
{
|
||||
return _isLiked;
|
||||
}
|
||||
|
||||
void Project::setIsLiked(bool newIsLiked)
|
||||
{
|
||||
_isLiked = newIsLiked;
|
||||
}
|
||||
|
||||
bool Project::isReady() const
|
||||
{
|
||||
return _isReady;
|
||||
}
|
||||
|
||||
void Project::setIsReady(bool newIsReady)
|
||||
{
|
||||
_isReady = newIsReady;
|
||||
}
|
||||
|
||||
Stages Project::stages() const
|
||||
{
|
||||
return _stages;
|
||||
}
|
||||
|
||||
void Project::setStages(const Stages &newStages)
|
||||
{
|
||||
_stages = newStages;
|
||||
}
|
||||
|
||||
QString Project::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void Project::setName(const QString &newName)
|
||||
{
|
||||
_name = newName;
|
||||
}
|
||||
|
||||
DeviceType::DeviceType() {}
|
||||
|
||||
int DeviceType::id() const
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
void DeviceType::setId(int newId)
|
||||
{
|
||||
_id = newId;
|
||||
}
|
||||
|
||||
QString DeviceType::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void DeviceType::setName(const QString &newName)
|
||||
{
|
||||
_name = newName;
|
||||
}
|
257
service/types.h
Normal file
@ -0,0 +1,257 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
class Types
|
||||
{
|
||||
public:
|
||||
Types();
|
||||
};
|
||||
|
||||
class Worker
|
||||
{
|
||||
public:
|
||||
Worker();
|
||||
|
||||
int id() const;
|
||||
void setId(int newId);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
int experience() const;
|
||||
void setExperience(int newExperience);
|
||||
|
||||
QString phoneNumber() const;
|
||||
void setPhoneNumber(const QString &newPhoneNumber);
|
||||
|
||||
QString teamName() const;
|
||||
void setTeamName(const QString &newTeamName);
|
||||
|
||||
private:
|
||||
int _id = 0;
|
||||
QString _name = "";
|
||||
int _experience = 0;
|
||||
QString _phoneNumber = "";
|
||||
QString _teamName = "";
|
||||
};
|
||||
|
||||
class Team
|
||||
{
|
||||
public:
|
||||
Team();
|
||||
|
||||
int id() const;
|
||||
void setId(int newId);
|
||||
|
||||
bool status() const;
|
||||
void setStatus(bool newStatus);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
private:
|
||||
int _id = 0;
|
||||
bool _status = true;
|
||||
QString _name = "";
|
||||
};
|
||||
|
||||
class Stages
|
||||
{
|
||||
public:
|
||||
Stages();
|
||||
|
||||
int id() const;
|
||||
void setId(int newId);
|
||||
|
||||
QDateTime StartDate() const;
|
||||
void setStartDate(const QDateTime &newStartDate);
|
||||
|
||||
QDateTime FinishDate() const;
|
||||
void setFinishDate(const QDateTime &newFinishDate);
|
||||
|
||||
int expenses() const;
|
||||
void setExpenses(int newExpenses);
|
||||
|
||||
QString nameWorker() const;
|
||||
void setNameWorker(const QString &newNameWorker);
|
||||
|
||||
int idWorker() const;
|
||||
void setIdWorker(int newIdWorker);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
bool completed() const;
|
||||
void setCompleted(bool newCompleted);
|
||||
|
||||
private:
|
||||
int _id = 0;
|
||||
QString _name = "";
|
||||
QDateTime _StartDate = QDateTime();
|
||||
QDateTime _FinishDate = QDateTime();
|
||||
bool _completed = "";
|
||||
int _expenses = 0;
|
||||
int _idWorker = 0;
|
||||
QString _nameWorker = "";
|
||||
};
|
||||
|
||||
class DeviceType
|
||||
{
|
||||
public:
|
||||
DeviceType();
|
||||
|
||||
int id() const;
|
||||
void setId(int newId);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
private:
|
||||
int _id = 0;
|
||||
QString _name = "";
|
||||
};
|
||||
|
||||
class DeviceStructureElement
|
||||
{
|
||||
public:
|
||||
DeviceStructureElement();
|
||||
|
||||
int id() const;
|
||||
void setId(int newId);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
QString description() const;
|
||||
void setDescription(const QString &newDescription);
|
||||
|
||||
int count() const;
|
||||
void setCount(int newCount);
|
||||
|
||||
QString nameType() const;
|
||||
void setNameType(const QString &newNameType);
|
||||
|
||||
private:
|
||||
int _id = 0;
|
||||
QString _name = "";
|
||||
QString _description = "";
|
||||
int _count = 1;
|
||||
QString _nameType = "";
|
||||
};
|
||||
|
||||
class DeviceModel
|
||||
{
|
||||
public:
|
||||
DeviceModel();
|
||||
|
||||
int id() const;
|
||||
void setId(int newId);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
QString description() const;
|
||||
void setDescription(const QString &newDescription);
|
||||
|
||||
int workEfficiency() const;
|
||||
void setWorkEfficiency(int newWorkEfficiency);
|
||||
|
||||
int reliability() const;
|
||||
void setReliability(int newReliability);
|
||||
|
||||
int durability() const;
|
||||
void setDurability(int newDurability);
|
||||
|
||||
QDateTime CreateDate() const;
|
||||
void setCreateDate(const QDateTime &newCreateDate);
|
||||
|
||||
QList<DeviceStructureElement> structureElements() const;
|
||||
void setStructureElements(const QList<DeviceStructureElement> &newStructureElements);
|
||||
|
||||
int idType() const;
|
||||
void setIdType(int newIdType);
|
||||
|
||||
QString nameType() const;
|
||||
void setNameType(const QString &newNameType);
|
||||
|
||||
private:
|
||||
int _id = 0;
|
||||
QString _name = "";
|
||||
QString _description = "";
|
||||
int _workEfficiency = 0;
|
||||
int _reliability = 0;
|
||||
int _durability = 0;
|
||||
int _idType = 0;
|
||||
QString _nameType = "";
|
||||
QDateTime _CreateDate = QDateTime();
|
||||
QList<DeviceStructureElement> _structureElements;
|
||||
};
|
||||
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
Project();
|
||||
|
||||
int id() const;
|
||||
void setId(int newId);
|
||||
|
||||
QString description() const;
|
||||
void setDescription(const QString &newDescription);
|
||||
|
||||
QDateTime StartProjectDate() const;
|
||||
void setStartProjectDate(const QDateTime &newStartProjectDate);
|
||||
|
||||
QDateTime FinishProjectDate() const;
|
||||
void setFinishProjectDate(const QDateTime &newFinishProjectDate);
|
||||
|
||||
double budget() const;
|
||||
void setBudget(double newBudget);
|
||||
|
||||
int idStages() const;
|
||||
void setIdStages(int newIdStages);
|
||||
|
||||
QString nameStages() const;
|
||||
void setNameStages(const QString &newNameStages);
|
||||
|
||||
int idTeam() const;
|
||||
void setIdTeam(int newIdTeam);
|
||||
|
||||
QString nameTeam() const;
|
||||
void setNameTeam(const QString &newNameTeam);
|
||||
|
||||
DeviceModel deviceModel() const;
|
||||
void setDeviceModel(const DeviceModel &newDeviceModel);
|
||||
|
||||
bool isLiked() const;
|
||||
void setIsLiked(bool newIsLiked);
|
||||
|
||||
bool isReady() const;
|
||||
void setIsReady(bool newIsReady);
|
||||
|
||||
Stages stages() const;
|
||||
void setStages(const Stages &newStages);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &newName);
|
||||
|
||||
private:
|
||||
int _id = 0;
|
||||
QString _description = "";
|
||||
QDateTime _StartProjectDate = QDateTime();
|
||||
QDateTime _FinishProjectDate = QDateTime();
|
||||
double _budget = 1;
|
||||
int _idStages = 0;
|
||||
QString _nameStages = "";
|
||||
int _idTeam = 0;
|
||||
QString _nameTeam = "";
|
||||
DeviceModel _deviceModel;
|
||||
Stages _stages;
|
||||
bool _isLiked = false;
|
||||
bool _isReady = true;
|
||||
QString _name = "";
|
||||
};
|
||||
|
||||
#endif // TYPES_H
|