qelectrotech-source-mirror/sources/qetgraphicsitem/ViewItem/ui/projectdbmodelpropertieswidget.cpp

107 lines
2.8 KiB
C++
Raw Normal View History

/*
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-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-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-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-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"
#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) :
PropertiesEditorWidget(parent),
2020-06-18 18:52:29 +02:00
ui(new Ui::ProjectDBModelPropertiesWidget)
{
2020-09-07 22:03:40 +02:00
ui->setupUi(this);
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-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;
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()
{
QDialog d(this);
auto l = new QVBoxLayout;
d.setLayout(l);
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);
}
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())
{
if (nom_w) {
m_model->setQuery(nom_w->queryStr());
} else if (sum_w) {
m_model->setQuery(sum_w->queryStr());
}
}
}
2020-09-07 22:03:40 +02:00
void ProjectDBModelPropertiesWidget::on_m_refresh_pb_clicked()
{
if (m_model && m_model->project()) {
m_model->project()->dataBase()->updateDB();
}
}