mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-19 18:19:58 +01:00
Merge remote-tracking branch 'origin/QetGraphicsTableItem'
This commit is contained in:
@@ -54,13 +54,12 @@ class BOMExportDialog : public QDialog
|
||||
void on_m_save_current_conf_pb_clicked();
|
||||
void on_m_load_pb_clicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
void setUpItems();
|
||||
QString getBom();
|
||||
QString headers() const;
|
||||
bool createDataBase();
|
||||
void populateDataBase();
|
||||
void prepareQuery(QStringList keys);
|
||||
QHash<QString, QString> elementInfoToString(Element *elmt) const;
|
||||
QString queryStr() const;
|
||||
void updateQueryLine();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2019 The QElectroTech Team
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user