mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-25 05:59:58 +02:00
Continue new summary feature
Header name is now well translated. Open the good dialog from the properties dock widget
This commit is contained in:
@@ -100,7 +100,7 @@ bool ProjectDBModel::setHeaderData(int section, Qt::Orientation orientation, con
|
||||
auto hash_ = m_header_data.value(section);
|
||||
hash_.insert(role, value);
|
||||
m_header_data.insert(section, hash_);
|
||||
headerDataChanged(orientation, section, section);
|
||||
emit headerDataChanged(orientation, section, section);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -329,29 +329,29 @@ void ProjectDBModel::dataBaseUpdated()
|
||||
|
||||
void ProjectDBModel::setHeaderString()
|
||||
{
|
||||
auto q = m_project->dataBase()->newQuery(m_query);
|
||||
auto record = q.record();
|
||||
auto q = m_project->dataBase()->newQuery(m_query);
|
||||
auto record = q.record();
|
||||
|
||||
for (auto i=0 ; i<record.count() ; ++i)
|
||||
{
|
||||
auto field_name = record.fieldName(i);
|
||||
QString header_name;
|
||||
for (auto i=0 ; i<record.count() ; ++i)
|
||||
{
|
||||
auto field_name = record.fieldName(i);
|
||||
QString header_name;
|
||||
|
||||
if (field_name == "position") {
|
||||
header_name = tr("Position");
|
||||
} else if (field_name == "diagram_position") {
|
||||
header_name = tr("Position du folio");
|
||||
} else {
|
||||
header_name = QETApp::elementTranslatedInfoKey(field_name);
|
||||
if (header_name.isEmpty()) {
|
||||
header_name = QETApp::diagramTranslatedInfoKey(field_name);
|
||||
}
|
||||
if (header_name.isEmpty()) {
|
||||
header_name = field_name;
|
||||
}
|
||||
}
|
||||
this->setHeaderData(i, Qt::Horizontal, header_name);
|
||||
}
|
||||
if (field_name == "position") {
|
||||
header_name = tr("Position");
|
||||
} else if (field_name == "diagram_position") {
|
||||
header_name = tr("Position du folio");
|
||||
} else {
|
||||
header_name = QETApp::elementTranslatedInfoKey(field_name);
|
||||
if (header_name.isEmpty()) {
|
||||
header_name = QETApp::diagramTranslatedInfoKey(field_name);
|
||||
}
|
||||
if (header_name.isEmpty()) {
|
||||
header_name = field_name;
|
||||
}
|
||||
}
|
||||
this->setHeaderData(i, Qt::Horizontal, header_name, Qt::DisplayRole);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectDBModel::fillValue()
|
||||
|
||||
@@ -31,6 +31,9 @@ class QETProject;
|
||||
* This class should be sufficient to display the content of the project data base from a query set by the method void ProjectDBModel::setQuery(const QString &query).
|
||||
* The indentifier method is used by widget editor to retrieve the good widget for edit the query. By defaut identifer return the string 'unknow'.
|
||||
* You should use setIdentfier method to set your custom identifier.
|
||||
* At the time this sentence is written, there is two identifier :
|
||||
* nomenclature
|
||||
* summary
|
||||
*/
|
||||
class ProjectDBModel : public QAbstractTableModel
|
||||
{
|
||||
@@ -53,7 +56,7 @@ class ProjectDBModel : public QAbstractTableModel
|
||||
QDomElement toXml(QDomDocument &document) const;
|
||||
void fromXml(const QDomElement &element);
|
||||
void setIdentifier(const QString &identifier);
|
||||
QString indentifier() const {return m_identifier;}
|
||||
QString identifier() const {return m_identifier;}
|
||||
static QString xmlTagName() {return QString("project_data_base_model");}
|
||||
|
||||
private:
|
||||
|
||||
@@ -132,7 +132,7 @@ void QetGraphicsHeaderItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||
QSize size(m_current_sections_width.at(i) - margins_.left() - margins_.right(), m_section_height - margins_.top() - margins_.bottom());
|
||||
painter->drawText(QRectF(top_left, size),
|
||||
m_model->headerData(0, Qt::Horizontal, Qt::TextAlignmentRole).toInt(),
|
||||
m_model->headerData(i, Qt::Horizontal).toString());
|
||||
m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
|
||||
|
||||
top_left.setX(top_left.x() + m_current_sections_width.at(i));
|
||||
}
|
||||
|
||||
@@ -56,12 +56,10 @@ class GraphicsTablePropertiesEditor : public PropertiesEditorWidget
|
||||
void on_m_previous_table_cb_activated(int index);
|
||||
void on_m_previous_pb_clicked();
|
||||
void on_m_next_pb_clicked();
|
||||
|
||||
void on_m_auto_geometry_pb_clicked();
|
||||
|
||||
void on_m_apply_geometry_to_linked_table_pb_clicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
void setUpEditConnection();
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "projectdbmodel.h"
|
||||
#include "qetproject.h"
|
||||
#include "elementquerywidget.h"
|
||||
#include "summaryquerywidget.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
@@ -62,9 +63,20 @@ void ProjectDBModelPropertiesWidget::on_m_edit_query_pb_clicked()
|
||||
auto l = new QVBoxLayout;
|
||||
d.setLayout(l);
|
||||
|
||||
auto query_widget = new ElementQueryWidget(&d);
|
||||
query_widget->setQuery(m_model->queryString());
|
||||
l->addWidget(query_widget);
|
||||
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);
|
||||
@@ -73,10 +85,10 @@ void ProjectDBModelPropertiesWidget::on_m_edit_query_pb_clicked()
|
||||
|
||||
if (d.exec())
|
||||
{
|
||||
m_model->setQuery(query_widget->queryStr());
|
||||
auto headers = query_widget->header();
|
||||
for (auto i=0 ; i<headers.size() ; ++i) {
|
||||
m_model->setHeaderData(i, Qt::Horizontal, headers.at(i));
|
||||
if (nom_w) {
|
||||
m_model->setQuery(nom_w->queryStr());
|
||||
} else if (sum_w) {
|
||||
m_model->setQuery(sum_w->queryStr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user