mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Improve opening time of terminal strip editor window
Need serious refactoring of codes who use the method Element::actualLabel() and also actualLabel itself. This part of code is crappy.
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include "../../utils/qetutils.h"
|
#include "../../utils/qetutils.h"
|
||||||
#include "../../qetgraphicsitem/terminalelement.h"
|
#include "../../qetgraphicsitem/terminalelement.h"
|
||||||
#include "../realterminal.h"
|
#include "../realterminal.h"
|
||||||
|
#include "../../qetinformation.h"
|
||||||
|
|
||||||
const int LABEL_CELL = 0;
|
const int LABEL_CELL = 0;
|
||||||
const int XREF_CELL = 1;
|
const int XREF_CELL = 1;
|
||||||
@@ -310,7 +311,8 @@ void FreeTerminalModel::fillTerminalVector()
|
|||||||
std::sort(free_terminal_vector.begin(), free_terminal_vector.end(),
|
std::sort(free_terminal_vector.begin(), free_terminal_vector.end(),
|
||||||
[](TerminalElement *a, TerminalElement *b)
|
[](TerminalElement *a, TerminalElement *b)
|
||||||
{
|
{
|
||||||
return QETUtils::sortBeginIntString(a->actualLabel(), b->actualLabel());
|
return QETUtils::sortBeginIntString(a->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString(),
|
||||||
|
b->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const auto &terminal_ : free_terminal_vector) {
|
for (const auto &terminal_ : free_terminal_vector) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "../realterminal.h"
|
#include "../realterminal.h"
|
||||||
#include "../../qetgraphicsitem/terminalelement.h"
|
#include "../../qetgraphicsitem/terminalelement.h"
|
||||||
#include "../terminalstrip.h"
|
#include "../terminalstrip.h"
|
||||||
|
#include "../../qetinformation.h"
|
||||||
|
|
||||||
TerminalStripTreeDockWidget::TerminalStripTreeDockWidget(QETProject *project, QWidget *parent) :
|
TerminalStripTreeDockWidget::TerminalStripTreeDockWidget(QETProject *project, QWidget *parent) :
|
||||||
QDockWidget(parent),
|
QDockWidget(parent),
|
||||||
@@ -305,8 +306,11 @@ void TerminalStripTreeDockWidget::addFreeTerminal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Sort the terminal element by label
|
//Sort the terminal element by label
|
||||||
std::sort(vector_.begin(), vector_.end(), [](TerminalElement *a, TerminalElement *b) {
|
std::sort(vector_.begin(), vector_.end(), [](TerminalElement *a, TerminalElement *b)
|
||||||
return a->actualLabel() < b->actualLabel();
|
{
|
||||||
|
return a->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString()
|
||||||
|
<
|
||||||
|
b->elementData().m_informations.value(QETInformation::ELMT_LABEL).toString();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto free_terminal_item = ui->m_tree_view->topLevelItem(1);
|
auto free_terminal_item = ui->m_tree_view->topLevelItem(1);
|
||||||
|
|||||||
@@ -198,14 +198,17 @@ QVector<TerminalElement *> ElementProvider::freeTerminal() const
|
|||||||
{
|
{
|
||||||
QVector<TerminalElement *> vector_;
|
QVector<TerminalElement *> vector_;
|
||||||
|
|
||||||
for (const auto diagram : m_diagram_list) {
|
for (const auto &diagram : qAsConst(m_diagram_list))
|
||||||
DiagramContent dc(diagram, false);
|
{
|
||||||
for (const auto element : qAsConst(dc.m_elements)) {
|
const auto elmt_list{diagram->elements()};
|
||||||
|
|
||||||
|
for (const auto element : elmt_list)
|
||||||
|
{
|
||||||
if (element->elementData().m_type == ElementData::Terminale)
|
if (element->elementData().m_type == ElementData::Terminale)
|
||||||
{
|
{
|
||||||
auto te = static_cast<TerminalElement *>(element);
|
const auto te{static_cast<TerminalElement *>(element)};
|
||||||
if (!te->parentTerminalStrip()) {
|
if (!te->parentTerminalStrip()) {
|
||||||
vector_.append(static_cast<TerminalElement *>(element));
|
vector_.append(te);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user