mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Fix Qt 6 definition of macro ‘Q_DECLARE_MOVABLE_CONTAINER’
adding #include <QHash> + code fail to compile if it uses deprecated APIs. => see .pro file
This commit is contained in:
@@ -15,13 +15,16 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QSettings>
|
||||
#include <QHash>
|
||||
|
||||
#include "multipastedialog.h"
|
||||
#include "ui_multipastedialog.h"
|
||||
#include "diagram.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "element.h"
|
||||
#include "conductorautonumerotation.h"
|
||||
#include <QSettings>
|
||||
|
||||
MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -29,16 +32,16 @@ MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
|
||||
m_diagram(diagram)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
connect(ui->m_x_sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
||||
connect(ui->m_y_sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
||||
connect(ui->m_copy_count, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
|
||||
|
||||
|
||||
QRectF br;
|
||||
for (QGraphicsItem *item : m_diagram->selectedItems())
|
||||
br = br.united(item->mapToScene(item->boundingRect()).boundingRect());
|
||||
m_origin = br.topLeft();
|
||||
|
||||
|
||||
m_document = m_diagram->toXml(false);
|
||||
updatePreview();
|
||||
}
|
||||
@@ -56,7 +59,7 @@ MultiPasteDialog::~MultiPasteDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -73,20 +76,20 @@ void MultiPasteDialog::updatePreview()
|
||||
}
|
||||
m_pasted_content.clear();
|
||||
m_pasted_content_list.clear();
|
||||
|
||||
|
||||
QPointF offset(ui->m_x_sb->value(), ui->m_y_sb->value());
|
||||
QPointF pos = m_origin+offset;
|
||||
|
||||
|
||||
for(int i=0 ; i<ui->m_copy_count->value() ; i++)
|
||||
{
|
||||
{
|
||||
DiagramContent dc;
|
||||
m_diagram->fromXml(m_document, pos, false, &dc);
|
||||
|
||||
|
||||
m_pasted_content += dc;
|
||||
m_pasted_content_list << dc;
|
||||
pos += offset;
|
||||
}
|
||||
|
||||
|
||||
if(m_pasted_content.count())
|
||||
m_diagram->adjustSceneRect();
|
||||
}
|
||||
@@ -96,7 +99,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
if(m_pasted_content.count())
|
||||
{
|
||||
m_diagram->undoStack().beginMacro(tr("Multi-collage"));
|
||||
|
||||
|
||||
QSettings settings;
|
||||
bool erase_label = settings.value("diagramcommands/erase-label-on-copy", true).toBool();
|
||||
//Ensure when 'auto_num' is checked, the settings 'save_label' is to true.
|
||||
@@ -105,18 +108,18 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
//and so the auto_num below do nothing (there is not a formula to compare)
|
||||
if(ui->m_auto_num_cb->isChecked())
|
||||
settings.setValue("diagramcommands/erase-label-on-copy", false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_diagram->clearSelection();
|
||||
m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, m_pasted_content));
|
||||
|
||||
|
||||
for(DiagramContent dc : m_pasted_content_list)
|
||||
{
|
||||
QList<Element *> pasted_elements = dc.m_elements;
|
||||
//Sort the list element by there pos (top -> bottom)
|
||||
std::sort(pasted_elements.begin(), pasted_elements.end(), [](Element *a, Element *b){return (a->pos().y() < b->pos().y());});
|
||||
|
||||
|
||||
//Auto-connection
|
||||
if(ui->m_auto_connection_cb->isChecked())
|
||||
{
|
||||
@@ -125,10 +128,10 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
while (!elmt->AlignedFreeTerminals().isEmpty())
|
||||
{
|
||||
QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst();
|
||||
|
||||
|
||||
Conductor *conductor = new Conductor(pair.first, pair.second);
|
||||
m_diagram->undoStack().push(new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF()));
|
||||
|
||||
|
||||
//Autonum the new conductor, the undo command associated for this, have for parent undo_object
|
||||
ConductorAutoNumerotation can (conductor, m_diagram);
|
||||
can.numerate();
|
||||
@@ -138,7 +141,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Set up the label of element
|
||||
//Instead of use the current autonum of project,
|
||||
//we try to fetch the same formula of the pasted element, in the several autonum of the project
|
||||
@@ -152,7 +155,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
{
|
||||
QHash <QString, NumerotationContext> autonums = m_diagram->project()->elementAutoNum();
|
||||
QHashIterator<QString, NumerotationContext> hash_iterator(autonums);
|
||||
|
||||
|
||||
while(hash_iterator.hasNext())
|
||||
{
|
||||
hash_iterator.next();
|
||||
@@ -167,7 +170,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
}
|
||||
//Like elements, we compare formula of pasted conductor with the autonums available in the project.
|
||||
if(ui->m_auto_num_cond_cb->isChecked())
|
||||
{
|
||||
{
|
||||
//This list is to ensure we not numerate twice the same conductor
|
||||
QList<Conductor *> numerated;
|
||||
//Start with the element at top
|
||||
@@ -184,7 +187,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
{
|
||||
QHash <QString, NumerotationContext> autonums = m_diagram->project()->conductorAutoNum();
|
||||
QHashIterator <QString, NumerotationContext> hash_iterator(autonums);
|
||||
|
||||
|
||||
while (hash_iterator.hasNext())
|
||||
{
|
||||
hash_iterator.next();
|
||||
@@ -205,7 +208,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_diagram->adjustSceneRect();
|
||||
m_accept = true;
|
||||
settings.setValue("diagramcommands/erase-label-on-copy", erase_label);
|
||||
|
||||
Reference in New Issue
Block a user