2020-04-12 18:51:38 +02:00
|
|
|
/*
|
2025-01-04 13:37:40 +01:00
|
|
|
Copyright 2006-2025 The QElectroTech Team
|
2020-08-16 09:40:14 +02:00
|
|
|
This file is part of QElectroTech.
|
2020-04-12 18:51:38 +02:00
|
|
|
|
2020-08-16 09:40:14 +02:00
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2020-04-12 18:51:38 +02:00
|
|
|
|
2020-08-16 09:40:14 +02:00
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2020-04-12 18:51:38 +02:00
|
|
|
|
2020-08-16 09:40:14 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
2020-04-12 18:51:38 +02:00
|
|
|
*/
|
2020-06-18 18:52:29 +02:00
|
|
|
#include "projectdbmodelpropertieswidget.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
|
|
|
#include "../../../dataBase/ui/elementquerywidget.h"
|
|
|
|
#include "../../../dataBase/ui/summaryquerywidget.h"
|
|
|
|
#include "../../../qetproject.h"
|
|
|
|
#include "../projectdbmodel.h"
|
2020-06-18 18:52:29 +02:00
|
|
|
#include "ui_projectdbmodelpropertieswidget.h"
|
2020-04-12 18:51:38 +02:00
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief projectDBModelPropertiesWidget::projectDBModelPropertiesWidget
|
|
|
|
@param model
|
|
|
|
@param parent
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
ProjectDBModelPropertiesWidget::ProjectDBModelPropertiesWidget(
|
|
|
|
ProjectDBModel *model,
|
|
|
|
QWidget *parent) :
|
2020-04-12 18:51:38 +02:00
|
|
|
PropertiesEditorWidget(parent),
|
2020-06-18 18:52:29 +02:00
|
|
|
ui(new Ui::ProjectDBModelPropertiesWidget)
|
2020-04-12 18:51:38 +02:00
|
|
|
{
|
2020-09-07 22:03:40 +02:00
|
|
|
ui->setupUi(this);
|
2020-04-12 18:51:38 +02:00
|
|
|
setModel(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief projectDBModelPropertiesWidget::~projectDBModelPropertiesWidget
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
ProjectDBModelPropertiesWidget::~ProjectDBModelPropertiesWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
2020-04-12 18:51:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief projectDBModelPropertiesWidget::setModel
|
|
|
|
@param model
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
void ProjectDBModelPropertiesWidget::setModel(ProjectDBModel *model)
|
|
|
|
{
|
|
|
|
m_model = model;
|
2020-04-12 18:51:38 +02:00
|
|
|
ui->m_edit_query_pb->setEnabled(m_model);
|
|
|
|
ui->m_refresh_pb->setEnabled(m_model);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief projectDBModelPropertiesWidget::on_m_edit_query_pb_clicked
|
|
|
|
*/
|
2020-06-18 18:52:29 +02:00
|
|
|
void ProjectDBModelPropertiesWidget::on_m_edit_query_pb_clicked()
|
2020-04-12 18:51:38 +02:00
|
|
|
{
|
|
|
|
QDialog d(this);
|
2020-04-29 11:48:45 +02:00
|
|
|
auto l = new QVBoxLayout;
|
2020-04-12 18:51:38 +02:00
|
|
|
d.setLayout(l);
|
|
|
|
|
2020-06-21 16:00:14 +02:00
|
|
|
ElementQueryWidget *nom_w = nullptr;
|
|
|
|
SummaryQueryWidget *sum_w = nullptr;
|
|
|
|
if (m_model->identifier() == "nomenclature")
|
|
|
|
{
|
|
|
|
nom_w = new ElementQueryWidget(&d);
|
|
|
|
nom_w->setQuery(m_model->queryString());
|
|
|
|
l->addWidget(nom_w);
|
|
|
|
}
|
|
|
|
else if (m_model->identifier() == "summary")
|
|
|
|
{
|
|
|
|
sum_w = new SummaryQueryWidget(&d);
|
|
|
|
sum_w->setQuery(m_model->queryString());
|
|
|
|
l->addWidget(sum_w);
|
|
|
|
}
|
2020-04-12 18:51:38 +02:00
|
|
|
|
|
|
|
auto button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
|
|
l->addWidget(button_box);
|
|
|
|
connect(button_box, &QDialogButtonBox::accepted, &d, &QDialog::accept);
|
|
|
|
connect(button_box, &QDialogButtonBox::rejected, &d, &QDialog::reject);
|
|
|
|
|
|
|
|
if (d.exec())
|
|
|
|
{
|
2020-06-21 16:00:14 +02:00
|
|
|
if (nom_w) {
|
|
|
|
m_model->setQuery(nom_w->queryStr());
|
|
|
|
} else if (sum_w) {
|
|
|
|
m_model->setQuery(sum_w->queryStr());
|
2020-04-12 18:51:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-07 22:03:40 +02:00
|
|
|
void ProjectDBModelPropertiesWidget::on_m_refresh_pb_clicked()
|
|
|
|
{
|
2020-04-12 18:51:38 +02:00
|
|
|
if (m_model && m_model->project()) {
|
|
|
|
m_model->project()->dataBase()->updateDB();
|
|
|
|
}
|
|
|
|
}
|