Refactoring.

Refactor elementProvider class  : Use the ElementData::Types instead of
deprecated Element::kind
This commit is contained in:
joshua
2022-06-13 20:22:10 +02:00
parent 0e9d09c62e
commit c83d4e5aea
5 changed files with 44 additions and 32 deletions

View File

@@ -17,13 +17,15 @@
*/
#include "linksingleelementwidget.h"
#include "../qetgraphicsitem/conductor.h"
#include "../diagram.h"
#include "../diagramposition.h"
#include "../qetgraphicsitem/element.h"
#include "../elementprovider.h"
#include "../qetgraphicsitem/conductor.h"
#include "../ui_linksingleelementwidget.h"
#include "../undocommand/linkelementcommand.h"
#include "../ui_linksingleelementwidget.h"
#include <QTreeWidgetItem>
/**
@@ -138,14 +140,15 @@ void LinkSingleElementWidget::setElement(Element *element)
//Setup the new element, connection and ui
m_element = element;
if (m_element->linkType() & Element::Slave)
m_filter = Element::Master;
else if (m_element->linkType() & Element::AllReport)
m_filter = m_element->linkType() == Element::NextReport
? Element::PreviousReport
: Element::NextReport;
const auto elmt_type{m_element->elementData().m_type};
if (elmt_type == ElementData::Slave)
m_filter = ElementData::Master;
else if (elmt_type & ElementData::AllReport)
m_filter = elmt_type == ElementData::NextReport
? ElementData::PreviousReport
: ElementData::NextReport;
else
m_filter = Element::Simple;
m_filter = ElementData::Simple;
connect(m_element->diagram()->project(), &QETProject::diagramRemoved,
this, &LinkSingleElementWidget::diagramWasRemovedFromProject);
@@ -376,7 +379,7 @@ QList <Element *> LinkSingleElementWidget::availableElements()
if (!m_element->diagram() || !m_element->diagram()->project()) return elmt_list;
ElementProvider ep(m_element->diagram()->project());
if (m_filter & Element::AllReport)
if (m_filter & ElementData::AllReport)
elmt_list = ep.freeElement(m_filter);
else
elmt_list = ep.find(m_filter);

View File

@@ -18,12 +18,14 @@
#ifndef LINKSINGLEELEMENTWIDGET_H
#define LINKSINGLEELEMENTWIDGET_H
#include "../qetgraphicsitem/element.h"
#include "../properties/elementdata.h"
#include "abstractelementpropertieseditorwidget.h"
#include <QHash>
class QTreeWidgetItem;
class Element;
class QMenu;
namespace Ui {
class LinkSingleElementWidget;
@@ -88,7 +90,7 @@ class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
Ui::LinkSingleElementWidget *ui;
bool m_unlink = false;
Element::kind m_filter;
ElementData::Type m_filter;
QHash <QTreeWidgetItem*, Element*> m_qtwi_elmt_hash;
QHash <QTreeWidgetItem*, QStringList> m_qtwi_strl_hash;
@@ -99,11 +101,11 @@ class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
Element *m_showed_element = nullptr,
*m_element_to_link = nullptr;
QMenu *m_context_menu;
QAction *m_link_action,
*m_show_qtwi,
*m_show_element,
*m_save_header_state;
QMenu *m_context_menu{nullptr};
QAction *m_link_action{nullptr},
*m_show_qtwi{nullptr},
*m_show_element{nullptr},
*m_save_header_state{nullptr};
};
#endif // LINKSINGLEELEMENTWIDGET_H

View File

@@ -258,7 +258,7 @@ void MasterPropertiesWidget::updateUi()
//Build the list of free available element
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)
{
QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_free_tree_widget);