Free hand selection : at the end of the selection, popup a context menu for create conductors between selected terminal

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5718 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2019-01-27 17:04:13 +00:00
parent a5b0658293
commit 0db73abd41
6 changed files with 336 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2019 The QElectroTech Team
Copyright 2006-2017 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -165,6 +165,51 @@ class LinkReportPotentialSelector : public AbstractPotentialSelector
//### END PRIVATE CLASS ###//
ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorProperties> list, QWidget *widget)
{
if (list.isEmpty()) {
return ConductorProperties() ;
} else if (list.size() == 1) {
return list.first();
}
QDialog dialog(widget);
QVBoxLayout layout(widget);
dialog.setLayout(&layout);
QLabel label(tr("Veuillez choisir un potentiel électrique de la liste \n"
"à utiliser pour le nouveau potentiel"));
layout.addWidget(&label);
QHash <QRadioButton *, ConductorProperties> H;
for (ConductorProperties cp : list)
{
QString text;
if(!cp.text.isEmpty())
text.append(tr("\nNuméro : %1").arg(cp.text));
if(!cp.m_function.isEmpty())
text.append(tr("\nFonction : %1").arg(cp.m_function));
if(!cp.m_tension_protocol.isEmpty())
text.append(tr("\nTension/protocole : %1").arg(cp.m_tension_protocol));
QRadioButton *b = new QRadioButton(text, &dialog);
layout.addWidget(b);
H.insert(b, cp);
}
QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok, &dialog);
layout.addWidget(button_box);
connect(button_box, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
dialog.exec();
for (QRadioButton *b : H.keys()) {
if(b->isChecked()) {
return H.value(b);
}
}
return ConductorProperties();
}
/**
* @brief PotentialSelectorDialog::PotentialSelectorDialog
* Constructor when we link two potentiels together, with a conductor

View File

@@ -1,5 +1,5 @@
/*
Copyright 2006-2019 The QElectroTech Team
Copyright 2006-2017 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
@@ -53,15 +53,22 @@ namespace Ui {
* as parent of the undo command that describe the changes.
* If @parent_undo is null, the created undo-command is push to the undo stack of the parent diagram of a conductor in potential.
* else we apply the change without a QUndoCommand.
*
* the static function chosenProperties, open a dialog who ask user to make a choice between the given
* properties
*/
class PotentialSelectorDialog : public QDialog
{
Q_OBJECT
public:
static ConductorProperties chosenProperties(QList<ConductorProperties> list, QWidget *parent = nullptr);
public:
explicit PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr);
explicit PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr);
~PotentialSelectorDialog() override;
private slots:
void on_buttonBox_accepted();