QETProject have is own database + add widget to edit nomenclature model

QETProject have is own ProjectDataBase, then when the database is
updated, everything that need the database is also updated trough the
signal emitted by the database.
Begin a widget to edit the NomenclatureModel
This commit is contained in:
Claveau Joshua
2020-03-29 18:17:27 +02:00
parent 66abfbe180
commit 8819146a01
16 changed files with 764 additions and 423 deletions

View File

@@ -16,19 +16,9 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "diagrampropertieseditordockwidget.h"
#include "elementpropertieswidget.h"
#include "diagram.h"
#include "element.h"
#include "diagramimageitem.h"
#include "imagepropertieswidget.h"
#include "qetshapeitem.h"
#include "shapegraphicsitempropertieswidget.h"
#include "dynamicelementtextitem.h"
#include "elementtextitemgroup.h"
#include "independenttextitem.h"
#include "inditextpropertieswidget.h"
#include "qetgraphicstableitem.h"
#include "graphicstablepropertieseditor.h"
#include "PropertiesEditor/propertieseditorwidget.h"
#include "propertieseditorfactory.h"
/**
* @brief DiagramPropertiesEditorDockWidget::DiagramPropertiesEditorDockWidget
@@ -81,176 +71,21 @@ void DiagramPropertiesEditorDockWidget::setDiagram(Diagram *diagram)
*/
void DiagramPropertiesEditorDockWidget::selectionChanged()
{
if (!m_diagram) return;
int count_ = m_diagram->selectedItems().size();
//The editor widget can only edit one item
//or several items of the same type
if (count_ != 1)
{
if (count_ == 0) {
clear();
m_edited_qgi_type = -1;
return;
}
const QList<QGraphicsItem *> list_ = m_diagram->selectedItems();
int type_ = list_.first()->type();
for (QGraphicsItem *qgi : list_)
{
if (qgi->type() != type_)
{
clear();
m_edited_qgi_type = -1;
return;
}
}
if (!m_diagram) {
return;
}
QGraphicsItem *item = m_diagram->selectedItems().first();
const int type_ = item->type();
switch (type_)
{
case Element::Type: //1000
{
if (count_ > 1)
{
clear();
m_edited_qgi_type = -1;
return;
}
//We already edit an element, just update the editor with a new element
if (m_edited_qgi_type == type_)
{
static_cast<ElementPropertiesWidget*>(editors().first())->setElement(static_cast<Element*>(item));
return;
}
clear();
m_edited_qgi_type = type_;
addEditor(new ElementPropertiesWidget(static_cast<Element*>(item), this));
break;
}
case IndependentTextItem::Type: //1005
{
QList<IndependentTextItem *> text_list;
for (QGraphicsItem *qgi : m_diagram->selectedItems()) {
text_list.append(static_cast<IndependentTextItem*>(qgi));
}
if (m_edited_qgi_type == type_)
{
static_cast<IndiTextPropertiesWidget*>(editors().first())->setText(text_list);
return;
}
clear();
m_edited_qgi_type = type_;
addEditor(new IndiTextPropertiesWidget(text_list, this));
break;
}
case DiagramImageItem::Type: //1007
{
if (count_ > 1)
{
clear();
m_edited_qgi_type = -1;
return;
}
clear();
m_edited_qgi_type = type_;
addEditor(new ImagePropertiesWidget(static_cast<DiagramImageItem*>(item), this));
break;
}
case QetShapeItem::Type: //1008
{
QList<QetShapeItem *> shapes_list;
for (QGraphicsItem *qgi : m_diagram->selectedItems()) {
shapes_list.append(static_cast<QetShapeItem*>(qgi));
}
if (m_edited_qgi_type == type_)
{
static_cast<ShapeGraphicsItemPropertiesWidget*>(editors().first())->setItems(shapes_list);
return;
}
clear();
m_edited_qgi_type = type_;
addEditor(new ShapeGraphicsItemPropertiesWidget(shapes_list, this));
break;
}
case DynamicElementTextItem::Type: //1010
{
if (count_ > 1)
{
clear();
m_edited_qgi_type = -1;
return;
}
DynamicElementTextItem *deti = static_cast<DynamicElementTextItem *>(item);
//For dynamic element text, we open the element editor to edit it
//If we already edit an element, just update the editor with a new element
if (m_edited_qgi_type == Element::Type)
{
static_cast<ElementPropertiesWidget*>(editors().first())->setDynamicText(deti);
return;
}
clear();
m_edited_qgi_type = Element::Type;
addEditor(new ElementPropertiesWidget(deti, this));
break;
}
case QGraphicsItemGroup::Type:
{
if (count_ > 1)
{
clear();
m_edited_qgi_type = -1;
return;
}
if(ElementTextItemGroup *group = dynamic_cast<ElementTextItemGroup *>(item))
{
//For element text item group, we open the element editor to edit it
//If we already edit an element, just update the editor with a new element
if(m_edited_qgi_type == Element::Type)
{
static_cast<ElementPropertiesWidget *>(editors().first())->setTextsGroup(group);
return;
}
clear();
m_edited_qgi_type = Element::Type;
addEditor(new ElementPropertiesWidget(group, this));
}
break;
}
case QetGraphicsTableItem::Type:
{
if (count_ > 1)
{
clear();
m_edited_qgi_type = -1;
return;
}
clear();
m_edited_qgi_type = type_;
addEditor(new GraphicsTablePropertiesEditor(static_cast<QetGraphicsTableItem*>(item), this));
break;
}
default:
m_edited_qgi_type = -1;
clear();
auto editor_ = PropertiesEditorFactory::propertiesEditor(m_diagram->selectedItems(), editors().count()? editors().first() : nullptr, this);
if (!editor_) {
clear();
return;
}
if (editors().count() &&
editors().first() != editor_) {
clear();
}
addEditor(editor_);
for (PropertiesEditorWidget *pew : editors()) {
pew->setLiveEdit(true);
}