diff --git a/qelectrotech.pro b/qelectrotech.pro
index 18a806bdc..250751189 100644
--- a/qelectrotech.pro
+++ b/qelectrotech.pro
@@ -102,6 +102,7 @@ INCLUDEPATH += sources \
sources/NameList/ui \
sources/utils \
sources/pugixml \
+ sources/dataBase
# Fichiers sources
@@ -130,7 +131,8 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \
$$files(sources/NameList/*.h) \
$$files(sources/NameList/ui/*.h) \
$$files(sources/utils/*.h) \
- $$files(sources/pugixml/*.hpp)
+ $$files(sources/pugixml/*.hpp) \
+ $$files(sources/dataBase/*.h)
SOURCES += $$files(sources/*.cpp) \
$$files(sources/editor/*.cpp) \
@@ -158,7 +160,8 @@ SOURCES += $$files(sources/*.cpp) \
$$files(sources/NameList/*.cpp) \
$$files(sources/NameList/ui/*.cpp) \
$$files(sources/utils/*.cpp) \
- $$files(sources/pugixml/*.cpp)
+ $$files(sources/pugixml/*.cpp) \
+ $$files(sources/dataBase/*.cpp)
# Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
RESOURCES += qelectrotech.qrc
diff --git a/sources/dataBase/projectdatabase.cpp b/sources/dataBase/projectdatabase.cpp
new file mode 100644
index 000000000..771a4dc29
--- /dev/null
+++ b/sources/dataBase/projectdatabase.cpp
@@ -0,0 +1,206 @@
+/*
+ Copyright 2006-2020 QElectroTech Team
+ This file is part of QElectroTech.
+
+ 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.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
+*/
+#include "projectdatabase.h"
+#include "qetapp.h"
+#include "qetproject.h"
+#include "elementprovider.h"
+#include "element.h"
+
+#include
+
+/**
+ * @brief projectDataBase::projectDataBase
+ * Default constructor
+ * @param project : project from the database work
+ * @param parent : parent QObject
+ */
+projectDataBase::projectDataBase(QETProject *project, QObject *parent) :
+ QObject(parent),
+ m_project(project)
+{
+ createDataBase();
+}
+
+/**
+ * @brief projectDataBase::~projectDataBase
+ * Destructor
+ */
+projectDataBase::~projectDataBase() {
+ m_data_base.close();
+}
+
+/**
+ * @brief projectDataBase::elementsInfoFromQuery
+ * @param query
+ * @return quickly return all information about elements from @query, ensure that all
+ * record returned by the query can be casted to string.
+ * Each item of the Qvector represent an element and each value of the QStringList represent the recorded value.
+ */
+QVector projectDataBase::elementsInfoFromQuery(const QString &query)
+{
+ QVector result_;
+
+ QSqlQuery query_(query, m_data_base);
+ if (!query_.exec()) {
+ qDebug() << "Query error : " << query_.lastError();
+ }
+
+ while (query_.next())
+ {
+ QStringList record_;
+ auto i=0;
+ while (query_.value(i).isValid())
+ {
+ record_ << query_.value(i).toString();
+ ++i;
+ }
+ result_ << record_;
+ }
+
+ return result_;
+}
+
+/**
+ * @brief projectDataBase::createDataBase
+ * Create the data base
+ * @return : true if the data base was successfully created.
+ */
+bool projectDataBase::createDataBase()
+{
+ QString connect_name("qet_project_db_" + m_project->uuid().toString());
+ if (m_data_base.connectionNames().contains(connect_name)) {
+ m_data_base = QSqlDatabase::database(connect_name);
+ }
+ else
+ {
+ m_data_base = QSqlDatabase::addDatabase("QSQLITE", connect_name);
+ if(!m_data_base.open())
+ {
+ m_data_base.close();
+ return false;
+ }
+
+ //Create the elements table
+ QString elements_table("CREATE TABLE element_info(");
+ bool first = true;
+ for (auto string : elementsInfoKeys())
+ {
+ if (first) {
+ first = false;
+ } else {
+ elements_table += ",";
+ }
+
+ elements_table += string += " VARCHAR(512)";
+ }
+ elements_table += ");";
+
+ QSqlQuery query_(elements_table, m_data_base);
+ query_.exec();
+ }
+
+ populateElementsTable();
+
+ return true;
+}
+
+/**
+ * @brief projectDataBase::populateElementsTable
+ * Populate the elements table
+ */
+void projectDataBase::populateElementsTable()
+{
+ //Very ugly, in futur we should update the table instead of delete all
+ QSqlQuery clear_table(m_data_base);
+ if (!clear_table.exec("DELETE FROM element_info")) {
+ qDebug() << "last error " << clear_table.lastError();
+ }
+
+ //Prepare the query used for insert new record
+ QStringList bind_values;
+ for (auto key : elementsInfoKeys()) {
+ bind_values << key.prepend(":");
+ }
+ QString insert("INSERT INTO element_info (" +
+ elementsInfoKeys().join(", ") +
+ ") VALUES (" +
+ bind_values.join(", ") +
+ ")");
+
+ QSqlQuery query(m_data_base);
+ query.prepare(insert);
+
+
+ for (auto *diagram : m_project->diagrams())
+ {
+ ElementProvider ep(diagram);
+ QList elements_list = ep.find(Element::Simple | Element::Terminale | Element::Master);
+
+ //Insert all value into the database
+ for (auto elmt : elements_list)
+ {
+ auto hash = elementInfoToString(elmt);
+ for (auto key : hash.keys())
+ {
+ QString value = hash.value(key);
+ QString bind = key.prepend(":");
+ query.bindValue(bind, value);
+ }
+
+ query.bindValue(":element_type", elmt->linkTypeToString());
+ query.bindValue(":element_subtype", elmt->kindInformations()["type"].toString());
+
+ if (!query.exec()) {
+ qDebug() << "projectDataBase::populateElementsTable insert error : " << query.lastError();
+ }
+ }
+ }
+}
+
+/**
+ * @brief projectDataBase::elementInfoToString
+ * @param elmt
+ * @return the element information in hash as key for the info name and value as the information value.
+ */
+QHash projectDataBase::elementInfoToString(Element *elmt)
+{
+ QHash hash; //Store the value for each columns
+ for (auto key : QETApp::elementInfoKeys())
+ {
+ if (key == "label") {
+ hash.insert(key, elmt->actualLabel());
+ }
+ else {
+ hash.insert(key, elmt->elementInformations()[key].toString());
+ }
+ }
+
+ return hash;
+}
+
+/**
+ * @brief projectDataBase::elementsInfoKeys
+ * @return QETApp::elementInfoKeys() + "element_type" and "element_subtype"
+ */
+QStringList projectDataBase::elementsInfoKeys() const
+{
+ auto keys_ = QETApp::elementInfoKeys();
+ keys_<< "element_type" << "element_subtype";
+
+ return keys_;
+}
diff --git a/sources/dataBase/projectdatabase.h b/sources/dataBase/projectdatabase.h
new file mode 100644
index 000000000..98ba65f18
--- /dev/null
+++ b/sources/dataBase/projectdatabase.h
@@ -0,0 +1,59 @@
+/*
+ Copyright 2006-2020 QElectroTech Team
+ This file is part of QElectroTech.
+
+ 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.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
+*/
+#ifndef PROJECTDATABASE_H
+#define PROJECTDATABASE_H
+
+#include
+#include
+#include
+#include
+
+#include "qetproject.h"
+
+class Element;
+
+/**
+ * @brief The projectDataBase class
+ * This class wrap a sqlite data base where you can find several thing about
+ * the content of a project.
+ *
+ * NOTE this class is still in developement.
+ */
+class projectDataBase : public QObject
+{
+ Q_OBJECT
+
+ public:
+ projectDataBase(QETProject *project, QObject *parent = nullptr);
+ virtual ~projectDataBase() override;
+
+ QVector elementsInfoFromQuery(const QString &query);
+
+ private:
+ bool createDataBase();
+ void populateElementsTable();
+ static QHash elementInfoToString(Element *elmt);
+ QStringList elementsInfoKeys() const;
+
+ private:
+ QPointer m_project;
+ QSqlDatabase m_data_base;
+ QSqlQuery m_insert_elements_query;
+};
+
+#endif // PROJECTDATABASE_H
diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp
index e99e22806..b05f29028 100644
--- a/sources/qetapp.cpp
+++ b/sources/qetapp.cpp
@@ -297,15 +297,15 @@ QStringList QETApp::elementInfoKeys()
<< "comment"
<< "function"
- << "tension-protocol"
+ << "tension_protocol"
<< "auxiliary1"
<< "auxiliary2"
<< "description"
<< "designation"
<< "manufacturer"
- << "manufacturer-reference"
- << "machine-manufacturer-reference"
+ << "manufacturer_reference"
+ << "machine_manufacturer_reference"
<< "supplier"
<< "quantity"
<< "unity";
@@ -328,15 +328,15 @@ QString QETApp::elementTranslatedInfoKey(const QString &info)
else if (info == "comment") return tr("Commentaire");
else if (info == "function") return tr("Fonction");
- else if (info == "tension-protocol") return tr("Tension / Protocole");
+ else if (info == "tension_protocol") return tr("Tension / Protocole");
else if (info == "auxiliary1") return tr("Bloc auxiliaire 1");
else if (info == "auxiliary2") return tr("Bloc auxiliaire 2");
else if (info == "description") return tr("Description textuelle");
else if (info == "designation") return tr("Numéro d'article");
else if (info == "manufacturer") return tr("Fabricant");
- else if (info == "manufacturer-reference") return tr("Numéro de commande");
- else if (info == "machine-manufacturer-reference") return tr("Numéro interne");
+ else if (info == "manufacturer_reference") return tr("Numéro de commande");
+ else if (info == "machine_manufacturer_reference") return tr("Numéro interne");
else if (info == "supplier") return tr("Fournisseur");
else if (info == "quantity") return tr("Quantité");
else if (info == "unity") return tr("Unité");
@@ -362,16 +362,16 @@ QString QETApp::elementInfoToVar(const QString &info)
else if (info == "description") return QString("%{description}");
else if (info == "designation") return QString("%{designation}");
else if (info == "manufacturer") return QString("%{manufacturer}");
- else if (info == "manufacturer-reference") return QString("%{manufacturer-reference}");
+ else if (info == "manufacturer_reference") return QString("%{manufacturer_reference}");
else if (info == "supplier") return QString("%{supplier}");
else if (info == "quantity") return QString("%{quantity}");
else if (info == "unity") return QString("%{unity}");
else if (info == "auxiliary1") return QString("%{auxiliary1}");
else if (info == "auxiliary2") return QString("%{auxiliary2}");
- else if (info == "machine-manufacturer-reference") return QString("%{machine-manufacturer-reference}");
+ else if (info == "machine_manufacturer_reference") return QString("%{machine_manufacturer_reference}");
else if (info == "location") return QString("%{location}");
else if (info == "function") return QString("%{function}");
- else if (info == "tension-protocol") return QString("%{tension-protocol}");
+ else if (info == "tension_protocol") return QString("%{tension_protocol}");
return (QString ("%{void}"));
}
diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp
index 010cb619a..ccd4e5dc2 100644
--- a/sources/qetdiagrameditor.cpp
+++ b/sources/qetdiagrameditor.cpp
@@ -50,6 +50,7 @@
#include "addelementtextcommand.h"
#include "conductornumexport.h"
#include "qetgraphicstableitem.h"
+#include "nomenclaturemodel.h"
#include
#include
@@ -403,9 +404,29 @@ void QETDiagramEditor::setUpActions()
//Add a nomenclature item
m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter un tableau lambda (Fonctionnalité en cours de devellopement)"),this);
- connect(m_add_nomenclature, &QAction::triggered, [this]() {
- if(this->currentDiagramView()) {
- this->currentDiagramView()->diagram()->addItem(new QetGraphicsTableItem());
+ connect(m_add_nomenclature, &QAction::triggered, [this]()
+ {
+ if(this->currentDiagramView())
+ {
+ auto table = new QetGraphicsTableItem();
+
+ /*******ONLY FOR TEST DURING DEVEL*********/
+ auto model = new NomenclatureModel(this->currentProject(), this->currentProject());
+ model->query("SELECT plant, location, label, comment, description FROM element_info ORDER BY plant, location, label, comment, description");
+ model->setData(model->index(0,0), Qt::AlignLeft, Qt::TextAlignmentRole);
+ model->setData(model->index(0,0), QETApp::diagramTextsFont(), Qt::FontRole);
+ model->setHeaderData(0, Qt::Horizontal, Qt::AlignHCenter, Qt::TextAlignmentRole);
+ model->setHeaderData(0, Qt::Horizontal, QETApp::diagramTextsFont(), Qt::FontRole);
+ model->setHeaderData(0, Qt::Horizontal, "Installation");
+ model->setHeaderData(1, Qt::Horizontal, "Localisation");
+ model->setHeaderData(2, Qt::Horizontal, "Label");
+ model->setHeaderData(3, Qt::Horizontal, "Commentaire");
+ model->setHeaderData(4, Qt::Horizontal, "Description");
+ table->setModel(model);
+ /******************************************/
+
+ this->currentDiagramView()->diagram()->addItem(table);
+ table->setPos(50,50);
}
});
diff --git a/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.cpp b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.cpp
new file mode 100644
index 000000000..56810089a
--- /dev/null
+++ b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.cpp
@@ -0,0 +1,164 @@
+/*
+ Copyright 2006-2020 QElectroTech Team
+ This file is part of QElectroTech.
+
+ 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.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
+*/
+#include "nomenclaturemodel.h"
+#include "qetapp.h"
+
+#include
+#include
+
+/**
+ * @brief NomenclatureModel::NomenclatureModel
+ * @param project :project of this nomenclature
+ * @param parent : parent QObject
+ */
+NomenclatureModel::NomenclatureModel(QETProject *project, QObject *parent) :
+ QAbstractTableModel(parent),
+ m_project(project),
+ m_database(project)
+{}
+
+/**
+ * @brief NomenclatureModel::rowCount
+ * Reimplemented for QAbstractTableModel
+ * @param parent
+ * @return
+ */
+int NomenclatureModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+
+ return m_record.count();
+}
+
+/**
+ * @brief NomenclatureModel::columnCount
+ * Reimplemented for QAbstractTableModel
+ * @param parent
+ * @return
+ */
+int NomenclatureModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+
+ if (m_record.count()) {
+ return m_record.first().count();
+ }
+
+ return 0;
+}
+
+/**
+ * @brief NomenclatureModel::setHeaderData
+ * Reimplemented from QAbstractTableModel.
+ * Only horizontal orientation is accepted.
+ * @param section
+ * @param orientation
+ * @param value
+ * @param role
+ * @return
+ */
+bool NomenclatureModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role)
+{
+ if (orientation == Qt::Vertical) {
+ return false;
+ }
+ auto hash_ = m_header_data.value(section);
+ hash_.insert(role, value);
+ m_header_data.insert(section, hash_);
+ headerDataChanged(orientation, section, section);
+ return true;
+}
+
+/**
+ * @brief NomenclatureModel::headerData
+ * Reimplemented from QAbstractTableModel.
+ * @param section
+ * @param orientation
+ * @param role
+ * @return
+ */
+QVariant NomenclatureModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Vertical) {
+ return QVariant();
+ }
+
+ auto hash_ = m_header_data.value(section);
+ if (role == Qt::DisplayRole && !hash_.contains(Qt::DisplayRole)) { //special case to have the same behavior as Qt
+ return hash_.value(Qt::EditRole);
+ }
+ return m_header_data.value(section).value(role);
+}
+
+/**
+ * @brief NomenclatureModel::setData
+ * Only store the data for the index 0.0
+ * @param index
+ * @param value
+ * @param role
+ * @return
+ */
+bool NomenclatureModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (!index.isValid() || index.row() != 0 || index.column() != 0) {
+ return false;
+ }
+ m_index_0_0_data.insert(role, value);
+ emit dataChanged(index, index, QVector(role));
+ return true;
+}
+
+/**
+ * @brief NomenclatureModel::data
+ * Reimplemented for QAbstractTableModel
+ * @param index
+ * @param role
+ * @return
+ */
+QVariant NomenclatureModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() == 0 &&
+ index.column() == 0 &&
+ role != Qt::DisplayRole) {
+ return m_index_0_0_data.value(role);
+ }
+
+ if (role == Qt::DisplayRole) {
+ QVariant v(m_record.at(index.row()).at(index.column()));
+ return v;
+ }
+
+ return QVariant();
+}
+
+/**
+ * @brief NomenclatureModel::query
+ * Query the internall bd with @query.
+ * @param query
+ */
+void NomenclatureModel::query(const QString &query)
+{
+ m_query = query;
+ m_record.clear();
+ m_record = m_database.elementsInfoFromQuery(query);
+}
diff --git a/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.h b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.h
new file mode 100644
index 000000000..500958135
--- /dev/null
+++ b/sources/qetgraphicsitem/ViewItem/nomenclaturemodel.h
@@ -0,0 +1,57 @@
+/*
+ Copyright 2006-2020 QElectroTech Team
+ This file is part of QElectroTech.
+
+ 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.
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
+*/
+#ifndef NOMENCLATUREMODEL_H
+#define NOMENCLATUREMODEL_H
+
+#include
+#include
+#include "projectdatabase.h"
+
+
+class QETProject;
+
+/**
+ * @brief The NomenclatureModel class
+ * An element nomenclature Model.
+ * This model represent a 2D data.
+ */
+class NomenclatureModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+ public:
+ explicit NomenclatureModel(QETProject *project, QObject *parent = nullptr);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ void query(const QString &query);
+
+ private:
+ QPointer m_project;
+ QString m_query;
+ projectDataBase m_database;
+ QVector m_record;
+ QHash> m_header_data;
+ QHash m_index_0_0_data;
+};
+
+#endif // NOMENCLATUREMODEL_H
diff --git a/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp b/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp
index ae47648d7..29a6a3ef0 100644
--- a/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp
+++ b/sources/qetgraphicsitem/ViewItem/qetgraphicsheaderitem.cpp
@@ -1,5 +1,5 @@
/*
- Copyright 2006-2019 QElectroTech Team
+ Copyright 2006-2020 QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
diff --git a/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp b/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp
index 7be9155f8..4d2be043e 100644
--- a/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp
+++ b/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.cpp
@@ -52,31 +52,6 @@ QetGraphicsTableItem::QetGraphicsTableItem(QGraphicsItem *parent) :
connect(m_header_item, &QetGraphicsHeaderItem::heightResized, this, [this]() {
m_header_item->setPos(0, 0-m_header_item->rect().height());
});
-
- /*******ONLY FOR TEST DURING DEVEL*********/
- auto model = new QStandardItemModel(this);
- int r = 20;
- int c = 5;
-
- for (int row = 0; row < r; ++row)
- {
- for (int column = 0; column < c; ++column) {
- QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
- model->setItem(row, column, item);
- }
- }
- model->setData(model->index(0,0), Qt::AlignLeft, Qt::TextAlignmentRole);
- model->setData(model->index(0,0), QETApp::diagramTextsFont(), Qt::FontRole);
- model->setHeaderData(0, Qt::Horizontal, Qt::AlignHCenter, Qt::TextAlignmentRole);
- model->setHeaderData(0, Qt::Horizontal, QETApp::diagramTextsFont(), Qt::FontRole);
- model->setHeaderData(0, Qt::Horizontal, "Label");
- model->setHeaderData(1, Qt::Horizontal, "Folio");
- model->setHeaderData(2, Qt::Horizontal, "Fonction");
- model->setHeaderData(3, Qt::Horizontal, "Fabricant");
- model->setHeaderData(4, Qt::Horizontal, "Installation");
- this->setModel(model);
- this->setPos(50,50);
- /******************************************/
}
QetGraphicsTableItem::~QetGraphicsTableItem()
@@ -399,7 +374,7 @@ void QetGraphicsTableItem::handlerMouseReleaseEvent(QGraphicsSceneMouseEvent *ev
void QetGraphicsTableItem::adjustColumnsWidth()
{
auto a = m_current_size.width() - minimumSize().width();
- auto b = a/m_model->columnCount();
+ auto b = a/std::max(1,m_model->columnCount()); //avoid divide by 0
for(auto i= 0 ; icolumnCount() ; ++i) {
m_header_item->resizeSection(i, std::max(m_minimum_column_width.at(i), m_header_item->minimumSectionWidth().at(i)) + b);
diff --git a/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.h b/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.h
index 96df2db67..7ce417a37 100644
--- a/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.h
+++ b/sources/qetgraphicsitem/ViewItem/qetgraphicstableitem.h
@@ -35,6 +35,8 @@ class QetGraphicsHeaderItem;
* Text font.
* Text alignment in the cell
* These two last parameters are not settable directly with the table but trough the model to be displayed by the table.
+ * The table search for font and alignment only in the index(0,0) for all the table.
+ * By consequence, set data in other index than 0,0 is useless also the alignment and font can't be set individually for each cell.
*/
class QetGraphicsTableItem : public QetGraphicsItem
{
diff --git a/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp b/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp
index f1aa0e309..06bf4db75 100644
--- a/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp
+++ b/sources/qetgraphicsitem/ViewItem/ui/graphicstablepropertieseditor.cpp
@@ -249,8 +249,10 @@ void GraphicsTablePropertiesEditor::updateUi()
return;
}
- m_header_button_group->button(m_table_item->model()->headerData(0, Qt::Horizontal, Qt::TextAlignmentRole).toInt())->setChecked(true);
- m_table_button_group->button(m_table_item->model()->data(m_table_item->model()->index(0,0), Qt::TextAlignmentRole).toInt())->setChecked(true);
+ if (auto button = m_header_button_group->button(m_table_item->model()->headerData(0, Qt::Horizontal, Qt::TextAlignmentRole).toInt()))
+ button->setChecked(true);
+ if (auto button = m_table_button_group->button(m_table_item->model()->data(m_table_item->model()->index(0,0), Qt::TextAlignmentRole).toInt()))
+ button->setChecked(true);
setUpEditConnection();
}
diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp
index edd7ce22d..506f5803e 100644
--- a/sources/qetproject.cpp
+++ b/sources/qetproject.cpp
@@ -112,6 +112,14 @@ QETProject::~QETProject() {
qDeleteAll(m_diagrams_list);
}
+/**
+ * @brief QETProject::uuid
+ * @return the uuid of this project
+ */
+QUuid QETProject::uuid() const {
+ return m_uuid;
+}
+
/**
* @brief QETProject::init
*/
diff --git a/sources/qetproject.h b/sources/qetproject.h
index 52887d189..1743dd7e8 100644
--- a/sources/qetproject.h
+++ b/sources/qetproject.h
@@ -71,6 +71,7 @@ class QETProject : public QObject
// methods
public:
+ QUuid uuid() const;
ProjectState state() const;
QList diagrams() const;
int getFolioSheetsQuantity() const; /// get the folio sheets quantity for this project
@@ -266,6 +267,7 @@ class QETProject : public QObject
QTimer m_save_backup_timer,
m_autosave_timer;
KAutoSaveFile *m_backup_file = nullptr;
+ QUuid m_uuid = QUuid::createUuid();
};
Q_DECLARE_METATYPE(QETProject *)