mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Refactoring.
Refactor elementProvider class : Use the ElementData::Types instead of deprecated Element::kind
This commit is contained in:
@@ -51,25 +51,32 @@ ElementProvider::ElementProvider(Diagram *diag) {
|
|||||||
ie element aren't connected with another element
|
ie element aren't connected with another element
|
||||||
@param filter
|
@param filter
|
||||||
the filter for search element
|
the filter for search element
|
||||||
(You can find all filter with the define in Element.h)
|
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QList <Element *> ElementProvider::freeElement(const int filter) const{
|
QList <Element *> ElementProvider::freeElement(ElementData::Types filter) const
|
||||||
QList <Element *> free_elmt;
|
{
|
||||||
|
QList<Element *> free_elmt;
|
||||||
|
QList<Element *> elmt_list;
|
||||||
|
|
||||||
//serch in all diagram
|
//serch in all diagram
|
||||||
foreach (Diagram *d, m_diagram_list) {
|
for (const auto &diagram_ : qAsConst(m_diagram_list))
|
||||||
//get all element in diagram d
|
{
|
||||||
QList <Element *> elmt_list;
|
//get all element in diagram d
|
||||||
elmt_list = d->elements();
|
elmt_list = diagram_->elements();
|
||||||
foreach (Element *elmt, elmt_list) {
|
for (const auto &elmt_ : qAsConst(elmt_list))
|
||||||
if (filter & elmt->linkType())
|
{
|
||||||
if (elmt->isFree()) free_elmt << elmt;
|
if (filter & elmt_->elementData().m_type &&
|
||||||
|
elmt_->isFree())
|
||||||
|
{
|
||||||
|
free_elmt << elmt_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//Clear for next loop
|
||||||
|
elmt_list.clear();
|
||||||
}
|
}
|
||||||
return (free_elmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return free_elmt;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
@brief ElementProvider::fromUuids
|
@brief ElementProvider::fromUuids
|
||||||
@param uuid_list list of uuid must be found
|
@param uuid_list list of uuid must be found
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ElementProvider
|
|||||||
public:
|
public:
|
||||||
ElementProvider(QETProject *prj, Diagram *diagram=nullptr);
|
ElementProvider(QETProject *prj, Diagram *diagram=nullptr);
|
||||||
ElementProvider(Diagram *diag);
|
ElementProvider(Diagram *diag);
|
||||||
QList <Element *> freeElement(const int filter) const;
|
QList <Element *> freeElement(ElementData::Types filter) const;
|
||||||
QList <Element *> fromUuids(QList <QUuid>) const;
|
QList <Element *> fromUuids(QList <QUuid>) const;
|
||||||
QList <Element *> find(const int filter) const;
|
QList <Element *> find(const int filter) const;
|
||||||
QVector<QPointer<Element> > find(ElementData::Types elmt_type) const;
|
QVector<QPointer<Element> > find(ElementData::Types elmt_type) const;
|
||||||
|
|||||||
@@ -17,13 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
#include "linksingleelementwidget.h"
|
#include "linksingleelementwidget.h"
|
||||||
|
|
||||||
|
#include "../qetgraphicsitem/conductor.h"
|
||||||
#include "../diagram.h"
|
#include "../diagram.h"
|
||||||
#include "../diagramposition.h"
|
#include "../diagramposition.h"
|
||||||
|
#include "../qetgraphicsitem/element.h"
|
||||||
#include "../elementprovider.h"
|
#include "../elementprovider.h"
|
||||||
#include "../qetgraphicsitem/conductor.h"
|
|
||||||
#include "../ui_linksingleelementwidget.h"
|
|
||||||
#include "../undocommand/linkelementcommand.h"
|
#include "../undocommand/linkelementcommand.h"
|
||||||
|
|
||||||
|
#include "../ui_linksingleelementwidget.h"
|
||||||
|
|
||||||
#include <QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,14 +140,15 @@ void LinkSingleElementWidget::setElement(Element *element)
|
|||||||
//Setup the new element, connection and ui
|
//Setup the new element, connection and ui
|
||||||
m_element = element;
|
m_element = element;
|
||||||
|
|
||||||
if (m_element->linkType() & Element::Slave)
|
const auto elmt_type{m_element->elementData().m_type};
|
||||||
m_filter = Element::Master;
|
if (elmt_type == ElementData::Slave)
|
||||||
else if (m_element->linkType() & Element::AllReport)
|
m_filter = ElementData::Master;
|
||||||
m_filter = m_element->linkType() == Element::NextReport
|
else if (elmt_type & ElementData::AllReport)
|
||||||
? Element::PreviousReport
|
m_filter = elmt_type == ElementData::NextReport
|
||||||
: Element::NextReport;
|
? ElementData::PreviousReport
|
||||||
|
: ElementData::NextReport;
|
||||||
else
|
else
|
||||||
m_filter = Element::Simple;
|
m_filter = ElementData::Simple;
|
||||||
|
|
||||||
connect(m_element->diagram()->project(), &QETProject::diagramRemoved,
|
connect(m_element->diagram()->project(), &QETProject::diagramRemoved,
|
||||||
this, &LinkSingleElementWidget::diagramWasRemovedFromProject);
|
this, &LinkSingleElementWidget::diagramWasRemovedFromProject);
|
||||||
@@ -376,7 +379,7 @@ QList <Element *> LinkSingleElementWidget::availableElements()
|
|||||||
if (!m_element->diagram() || !m_element->diagram()->project()) return elmt_list;
|
if (!m_element->diagram() || !m_element->diagram()->project()) return elmt_list;
|
||||||
|
|
||||||
ElementProvider ep(m_element->diagram()->project());
|
ElementProvider ep(m_element->diagram()->project());
|
||||||
if (m_filter & Element::AllReport)
|
if (m_filter & ElementData::AllReport)
|
||||||
elmt_list = ep.freeElement(m_filter);
|
elmt_list = ep.freeElement(m_filter);
|
||||||
else
|
else
|
||||||
elmt_list = ep.find(m_filter);
|
elmt_list = ep.find(m_filter);
|
||||||
|
|||||||
@@ -18,12 +18,14 @@
|
|||||||
#ifndef LINKSINGLEELEMENTWIDGET_H
|
#ifndef LINKSINGLEELEMENTWIDGET_H
|
||||||
#define LINKSINGLEELEMENTWIDGET_H
|
#define LINKSINGLEELEMENTWIDGET_H
|
||||||
|
|
||||||
#include "../qetgraphicsitem/element.h"
|
#include "../properties/elementdata.h"
|
||||||
#include "abstractelementpropertieseditorwidget.h"
|
#include "abstractelementpropertieseditorwidget.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
class Element;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class LinkSingleElementWidget;
|
class LinkSingleElementWidget;
|
||||||
@@ -88,7 +90,7 @@ class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
|
|||||||
Ui::LinkSingleElementWidget *ui;
|
Ui::LinkSingleElementWidget *ui;
|
||||||
|
|
||||||
bool m_unlink = false;
|
bool m_unlink = false;
|
||||||
Element::kind m_filter;
|
ElementData::Type m_filter;
|
||||||
|
|
||||||
QHash <QTreeWidgetItem*, Element*> m_qtwi_elmt_hash;
|
QHash <QTreeWidgetItem*, Element*> m_qtwi_elmt_hash;
|
||||||
QHash <QTreeWidgetItem*, QStringList> m_qtwi_strl_hash;
|
QHash <QTreeWidgetItem*, QStringList> m_qtwi_strl_hash;
|
||||||
@@ -99,11 +101,11 @@ class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
|
|||||||
Element *m_showed_element = nullptr,
|
Element *m_showed_element = nullptr,
|
||||||
*m_element_to_link = nullptr;
|
*m_element_to_link = nullptr;
|
||||||
|
|
||||||
QMenu *m_context_menu;
|
QMenu *m_context_menu{nullptr};
|
||||||
QAction *m_link_action,
|
QAction *m_link_action{nullptr},
|
||||||
*m_show_qtwi,
|
*m_show_qtwi{nullptr},
|
||||||
*m_show_element,
|
*m_show_element{nullptr},
|
||||||
*m_save_header_state;
|
*m_save_header_state{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LINKSINGLEELEMENTWIDGET_H
|
#endif // LINKSINGLEELEMENTWIDGET_H
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ void MasterPropertiesWidget::updateUi()
|
|||||||
|
|
||||||
//Build the list of free available element
|
//Build the list of free available element
|
||||||
QList <QTreeWidgetItem *> items_list;
|
QList <QTreeWidgetItem *> items_list;
|
||||||
const QList<Element *> free_list = elmt_prov.freeElement(Element::Slave);
|
const QList<Element *> free_list = elmt_prov.freeElement(ElementData::Slave);
|
||||||
for(Element *elmt : free_list)
|
for(Element *elmt : free_list)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_free_tree_widget);
|
QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_free_tree_widget);
|
||||||
|
|||||||
Reference in New Issue
Block a user