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:
Simon De Backer 2020-09-21 21:19:50 +02:00
parent c958d54d01
commit 2a69e540d6
25 changed files with 207 additions and 165 deletions

View File

@ -76,6 +76,7 @@ include(sources/QWidgetAnimation/QWidgetAnimation.pri)
DEFINES += QAPPLICATION_CLASS=QApplication DEFINES += QAPPLICATION_CLASS=QApplication
DEFINES += QT_MESSAGELOGCONTEXT DEFINES += QT_MESSAGELOGCONTEXT
DEFINES += GIT_COMMIT_SHA="\\\"$(shell git -C \""$$_PRO_FILE_PWD_"\" rev-parse --verify HEAD)\\\"" DEFINES += GIT_COMMIT_SHA="\\\"$(shell git -C \""$$_PRO_FILE_PWD_"\" rev-parse --verify HEAD)\\\""
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
TEMPLATE = app TEMPLATE = app
DEPENDPATH += . DEPENDPATH += .

View File

@ -19,6 +19,7 @@
#define ELEMENTSCOLLECTIONMODEL2_H #define ELEMENTSCOLLECTIONMODEL2_H
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QHash>
#include "elementslocation.h" #include "elementslocation.h"
class XmlProjectElementCollectionItem; class XmlProjectElementCollectionItem;

View File

@ -1,25 +1,27 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef NAMELISTWIDGET_H #ifndef NAMELISTWIDGET_H
#define NAMELISTWIDGET_H #define NAMELISTWIDGET_H
#include "nameslist.h"
#include <QWidget> #include <QWidget>
#include <QHash>
#include "nameslist.h"
namespace Ui { namespace Ui {
class NameListWidget; class NameListWidget;
@ -32,27 +34,27 @@ namespace Ui {
class NameListWidget : public QWidget class NameListWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit NameListWidget(QWidget *parent = nullptr); explicit NameListWidget(QWidget *parent = nullptr);
~NameListWidget(); ~NameListWidget();
void addLine(); void addLine();
void setNames (const NamesList &name_list); void setNames (const NamesList &name_list);
NamesList names() const; NamesList names() const;
void setReadOnly(bool ro); void setReadOnly(bool ro);
bool isEmpty() const; bool isEmpty() const;
void setClipboardValue (QHash <QString, QString> value); void setClipboardValue (QHash <QString, QString> value);
private slots: private slots:
void on_m_clipboard_cb_activated(int index); void on_m_clipboard_cb_activated(int index);
private: private:
void clean(); void clean();
private: private:
Ui::NameListWidget *ui; Ui::NameListWidget *ui;
bool m_read_only = false; bool m_read_only = false;
}; };
#endif // NAMELISTWIDGET_H #endif // NAMELISTWIDGET_H

View File

@ -1,20 +1,26 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QFontDialog>
#include <QFont>
#include <QSizePolicy>
#include <utility>
#include "configpages.h" #include "configpages.h"
#include "borderpropertieswidget.h" #include "borderpropertieswidget.h"
#include "conductorpropertieswidget.h" #include "conductorpropertieswidget.h"
@ -27,10 +33,7 @@
#include "qetproject.h" #include "qetproject.h"
#include "reportproperties.h" #include "reportproperties.h"
#include "qetapp.h" #include "qetapp.h"
#include <QFontDialog> #include "nameslist.h"
#include <QFont>
#include <QSizePolicy>
#include <utility>
/** /**
@brief NewDiagramPage::NewDiagramPage @brief NewDiagramPage::NewDiagramPage
@ -249,13 +252,13 @@ void NewDiagramPage::loadSavedTbp()
ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) { ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export // epw contient les options d'export
epw = new ExportPropertiesWidget(ExportProperties::defaultExportProperties()); epw = new ExportPropertiesWidget(ExportProperties::defaultExportProperties());
// layout vertical contenant le titre, une ligne horizontale et epw // layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout *vlayout1 = new QVBoxLayout(); QVBoxLayout *vlayout1 = new QVBoxLayout();
QLabel *title = new QLabel(this -> title()); QLabel *title = new QLabel(this -> title());
vlayout1 -> addWidget(title); vlayout1 -> addWidget(title);
QFrame *horiz_line = new QFrame(); QFrame *horiz_line = new QFrame();
horiz_line -> setFrameShape(QFrame::HLine); horiz_line -> setFrameShape(QFrame::HLine);
vlayout1 -> addWidget(horiz_line); vlayout1 -> addWidget(horiz_line);
@ -300,13 +303,13 @@ PrintConfigPage::PrintConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export // epw contient les options d'export
epw = new ExportPropertiesWidget(ExportProperties::defaultPrintProperties()); epw = new ExportPropertiesWidget(ExportProperties::defaultPrintProperties());
epw -> setPrintingMode(true); epw -> setPrintingMode(true);
// layout vertical contenant le titre, une ligne horizontale et epw // layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout *vlayout1 = new QVBoxLayout(); QVBoxLayout *vlayout1 = new QVBoxLayout();
QLabel *title = new QLabel(this -> title()); QLabel *title = new QLabel(this -> title());
vlayout1 -> addWidget(title); vlayout1 -> addWidget(title);
QFrame *horiz_line = new QFrame(); QFrame *horiz_line = new QFrame();
horiz_line -> setFrameShape(QFrame::HLine); horiz_line -> setFrameShape(QFrame::HLine);
vlayout1 -> addWidget(horiz_line); vlayout1 -> addWidget(horiz_line);
@ -329,10 +332,10 @@ PrintConfigPage::~PrintConfigPage()
void PrintConfigPage::applyConf() void PrintConfigPage::applyConf()
{ {
QString prefix = "print/default"; QString prefix = "print/default";
QSettings settings; QSettings settings;
epw -> exportProperties().toSettings(settings, prefix); epw -> exportProperties().toSettings(settings, prefix);
// annule l'enregistrement de certaines proprietes non pertinentes // annule l'enregistrement de certaines proprietes non pertinentes
settings.remove(prefix + "path"); settings.remove(prefix + "path");
settings.remove(prefix + "format"); settings.remove(prefix + "format");

View File

@ -20,6 +20,7 @@
#include <QWidget> #include <QWidget>
#include <QButtonGroup> #include <QButtonGroup>
#include <QHash>
class QListWidgetItem; class QListWidgetItem;

View File

@ -20,6 +20,7 @@
#include <QSet> #include <QSet>
#include <QPointF> #include <QPointF>
#include <QHash>
class QGraphicsItem; class QGraphicsItem;
class DiagramTextItem; class DiagramTextItem;
@ -37,16 +38,16 @@ class ElementTextsMover
ElementTextsMover(); ElementTextsMover();
private: private:
ElementTextsMover(const ElementTextsMover &); ElementTextsMover(const ElementTextsMover &);
public: public:
bool isReady() const; bool isReady() const;
int beginMovement(Diagram *diagram, QGraphicsItem *driver_item = nullptr); int beginMovement(Diagram *diagram, QGraphicsItem *driver_item = nullptr);
void continueMovement(QGraphicsSceneMouseEvent *event); void continueMovement(QGraphicsSceneMouseEvent *event);
void endMovement(); void endMovement();
private: private:
QString undoText() const; QString undoText() const;
private: private:
bool m_movement_running = false; bool m_movement_running = false;
Diagram *m_diagram = nullptr; Diagram *m_diagram = nullptr;

View File

@ -15,9 +15,11 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QMetaEnum>
#include <QHash>
#include "xrefproperties.h" #include "xrefproperties.h"
#include "qetapp.h" #include "qetapp.h"
#include <QMetaEnum>
/** /**
@brief XRefProperties::XRefProperties @brief XRefProperties::XRefProperties
@ -56,7 +58,7 @@ void XRefProperties::toSettings(QSettings &settings,
QString slave_label = m_slave_label; QString slave_label = m_slave_label;
settings.setValue(prefix + "slave_label", slave_label); settings.setValue(prefix + "slave_label", slave_label);
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>(); QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos)); settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos));
@ -110,7 +112,7 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
xml_element.setAttribute("snapto", snap); xml_element.setAttribute("snapto", snap);
QString xrefpos; QString xrefpos;
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>(); QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos)); xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos));

View File

@ -18,8 +18,10 @@
#ifndef XREFPROPERTIES_H #ifndef XREFPROPERTIES_H
#define XREFPROPERTIES_H #define XREFPROPERTIES_H
#include "propertiesinterface.h"
#include <QStringList> #include <QStringList>
#include <QHash>
#include "propertiesinterface.h"
/** /**
@brief The XRefProperties class @brief The XRefProperties class

View File

@ -1,23 +1,27 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef ELEMENT_H #ifndef ELEMENT_H
#define ELEMENT_H #define ELEMENT_H
#include <algorithm>
#include <QPicture>
#include <QHash>
#include "qet.h" #include "qet.h"
#include "qetgraphicsitem.h" #include "qetgraphicsitem.h"
#include "diagramcontext.h" #include "diagramcontext.h"
@ -25,9 +29,6 @@
#include "elementslocation.h" #include "elementslocation.h"
#include "nameslist.h" #include "nameslist.h"
#include <algorithm>
#include <QPicture>
class QETProject; class QETProject;
class Terminal; class Terminal;
class Conductor; class Conductor;
@ -40,7 +41,7 @@ class ElementTextItemGroup;
class Element : public QetGraphicsItem class Element : public QetGraphicsItem
{ {
friend class DiagramEventAddElement; friend class DiagramEventAddElement;
Q_OBJECT Q_OBJECT
public: public:
/** /**
@ -64,7 +65,7 @@ class Element : public QetGraphicsItem
~Element() override; ~Element() override;
private: private:
Element(const Element &); Element(const Element &);
// attributes // attributes
public: public:
/** /**
@ -74,7 +75,7 @@ class Element : public QetGraphicsItem
*/ */
enum { Type = UserType + 1000 }; enum { Type = UserType + 1000 };
int type() const override { return Type; } int type() const override { return Type; }
signals: signals:
void linkedElementChanged(); //This signal is emited when the linked elements with this element change void linkedElementChanged(); //This signal is emited when the linked elements with this element change
void elementInfoChange( void elementInfoChange(
@ -91,12 +92,12 @@ class Element : public QetGraphicsItem
DynamicElementTextItem *text, DynamicElementTextItem *text,
ElementTextItemGroup *group); ElementTextItemGroup *group);
public: public:
QList<Terminal *> terminals() const; QList<Terminal *> terminals() const;
QList<Conductor *> conductors() const; QList<Conductor *> conductors() const;
QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const; QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const;
//METHODS related to information //METHODS related to information
DiagramContext elementInformations()const DiagramContext elementInformations()const
{return m_element_informations;} {return m_element_informations;}
@ -118,7 +119,7 @@ class Element : public QetGraphicsItem
bool isFreezeLabel() const {return m_freeze_label;} bool isFreezeLabel() const {return m_freeze_label;}
void freezeNewAddedElement(); void freezeNewAddedElement();
QString actualLabel(); QString actualLabel();
QString name() const override; QString name() const override;
ElementsLocation location() const; ElementsLocation location() const;
virtual void setHighlighted(bool); virtual void setHighlighted(bool);
@ -140,7 +141,7 @@ class Element : public QetGraphicsItem
int> &) const; int> &) const;
QUuid uuid() const; QUuid uuid() const;
int orientation() const; int orientation() const;
//METHODS related to texts //METHODS related to texts
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr); void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
void removeDynamicTextItem(DynamicElementTextItem *deti); void removeDynamicTextItem(DynamicElementTextItem *deti);
@ -156,7 +157,7 @@ class Element : public QetGraphicsItem
bool removeTextFromGroup( bool removeTextFromGroup(
DynamicElementTextItem *text, DynamicElementTextItem *text,
ElementTextItemGroup *group); ElementTextItemGroup *group);
//METHODS related to linked element //METHODS related to linked element
bool isFree() const; bool isFree() const;
virtual void linkToElement(Element *) {} virtual void linkToElement(Element *) {}
@ -171,7 +172,7 @@ class Element : public QetGraphicsItem
protected: protected:
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *); void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
void setSize(int, int); void setSize(int, int);
private: private:
void drawSelection( void drawSelection(
QPainter *, QPainter *,
@ -212,25 +213,25 @@ class Element : public QetGraphicsItem
// to be use in the function element::fromXml // to be use in the function element::fromXml
QHash <DynamicElementTextItem *, QPointF> QHash <DynamicElementTextItem *, QPointF>
m_converted_text_from_xml_description; m_converted_text_from_xml_description;
//ATTRIBUTES related to linked element //ATTRIBUTES related to linked element
QList <Element *> connected_elements; QList <Element *> connected_elements;
QList <QUuid> tmp_uuids_link; QList <QUuid> tmp_uuids_link;
QUuid m_uuid; QUuid m_uuid;
kind m_link_type = Element::Simple; kind m_link_type = Element::Simple;
//ATTRIBUTES related to informations //ATTRIBUTES related to informations
DiagramContext m_element_informations, m_kind_informations; DiagramContext m_element_informations, m_kind_informations;
autonum::sequentialNumbers m_autoNum_seq; autonum::sequentialNumbers m_autoNum_seq;
bool m_freeze_label = false; bool m_freeze_label = false;
QString m_F_str; QString m_F_str;
ElementsLocation m_location; ElementsLocation m_location;
NamesList m_names; NamesList m_names;
QList <Terminal *> m_terminals; QList <Terminal *> m_terminals;
const QPicture m_picture; const QPicture m_picture;
const QPicture m_low_zoom_picture; const QPicture m_low_zoom_picture;
private: private:
bool m_must_highlight = false; bool m_must_highlight = false;
QSize dimensions; QSize dimensions;

View File

@ -1,25 +1,26 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "qetinformation.h"
#include <QObject> #include <QObject>
#include <QHash> #include <QHash>
#include "qetinformation.h"
/** /**
@brief QETInformation::titleblockInfoKeys @brief QETInformation::titleblockInfoKeys
@return all available key for use with a titleblock @return all available key for use with a titleblock
@ -47,7 +48,7 @@ QStringList QETInformation::titleblockInfoKeys()
info_list << "savedtime"; info_list << "savedtime";
info_list << "savedfilename"; info_list << "savedfilename";
info_list << "savedfilepath"; info_list << "savedfilepath";
return info_list; return info_list;
} }

View File

@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -19,6 +19,7 @@
#define QETINFORMATION_H #define QETINFORMATION_H
#include <QStringList> #include <QStringList>
#include <QHash>
namespace QETInformation namespace QETInformation
{ {

View File

@ -15,6 +15,13 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QTimer>
#include <QStandardPaths>
#include <utility>
#include <QtConcurrent>
#include <QHash>
#include "qetproject.h" #include "qetproject.h"
#include "diagram.h" #include "diagram.h"
#include "qetapp.h" #include "qetapp.h"
@ -30,11 +37,6 @@
#include "numerotationcontextcommands.h" #include "numerotationcontextcommands.h"
#include "assignvariables.h" #include "assignvariables.h"
#include <QTimer>
#include <QStandardPaths>
#include <utility>
#include <QtConcurrent>
static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
/** /**

View File

@ -1,23 +1,26 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef QET_PROJECT_H #ifndef QET_PROJECT_H
#define QET_PROJECT_H #define QET_PROJECT_H
#include <KAutoSaveFile>
#include <QHash>
#include "nameslist.h" #include "nameslist.h"
#include "elementslocation.h" #include "elementslocation.h"
#include "borderproperties.h" #include "borderproperties.h"
@ -28,8 +31,6 @@
#include "projectdatabase.h" #include "projectdatabase.h"
#include "reportproperties.h" #include "reportproperties.h"
#include <KAutoSaveFile>
class Diagram; class Diagram;
class ElementsLocation; class ElementsLocation;
class QETResult; class QETResult;
@ -62,7 +63,7 @@ class QETProject : public QObject
}; };
Q_PROPERTY(bool autoConductor READ autoConductor WRITE setAutoConductor) Q_PROPERTY(bool autoConductor READ autoConductor WRITE setAutoConductor)
// constructors, destructor // constructors, destructor
public: public:
QETProject (QObject *parent = nullptr); QETProject (QObject *parent = nullptr);
@ -72,7 +73,7 @@ class QETProject : public QObject
private: private:
QETProject(const QETProject &); QETProject(const QETProject &);
// methods // methods
public: public:
projectDataBase *dataBase(); projectDataBase *dataBase();
@ -166,13 +167,13 @@ class QETProject : public QObject
DiagramContext projectProperties(); DiagramContext projectProperties();
void setProjectProperties(const DiagramContext &); void setProjectProperties(const DiagramContext &);
QUndoStack* undoStack() {return m_undo_stack;} QUndoStack* undoStack() {return m_undo_stack;}
public slots: public slots:
Diagram *addNewDiagram(int pos = -1); Diagram *addNewDiagram(int pos = -1);
void removeDiagram(Diagram *); void removeDiagram(Diagram *);
void diagramOrderChanged(int, int); void diagramOrderChanged(int, int);
void setModified(bool); void setModified(bool);
signals: signals:
void projectFilePathChanged(QETProject *, const QString &); void projectFilePathChanged(QETProject *, const QString &);
void projectTitleChanged(QETProject *, const QString &); void projectTitleChanged(QETProject *, const QString &);
@ -195,14 +196,14 @@ class QETProject : public QObject
void folioAutoNumChanged(QString); void folioAutoNumChanged(QString);
void defaultTitleBlockPropertiesChanged(); void defaultTitleBlockPropertiesChanged();
void conductorAutoNumChanged(); void conductorAutoNumChanged();
private slots: private slots:
void updateDiagramsFolioData(); void updateDiagramsFolioData();
void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &); void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &); void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
void usedTitleBlockTemplateChanged(const QString &); void usedTitleBlockTemplateChanged(const QString &);
void undoStackChanged (bool a) {if (!a) setModified(true);} void undoStackChanged (bool a) {if (!a) setModified(true);}
private: private:
void readProjectXml(QDomDocument &xml_project); void readProjectXml(QDomDocument &xml_project);
void readDiagramsXml(QDomDocument &xml_project); void readDiagramsXml(QDomDocument &xml_project);
@ -217,7 +218,7 @@ class QETProject : public QObject
void writeBackup(); void writeBackup();
void init(); void init();
ProjectState openFile(QFile *file); ProjectState openFile(QFile *file);
// attributes // attributes
private: private:
/// File path this project is saved to /// File path this project is saved to

View File

@ -19,6 +19,8 @@
#define DYNAMICELEMENTTEXTMODEL_H #define DYNAMICELEMENTTEXTMODEL_H
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QHash>
#include <qstyleditemdelegate.h> #include <qstyleditemdelegate.h>
#include "dynamicelementtextitem.h" #include "dynamicelementtextitem.h"
@ -35,7 +37,7 @@ class Element;
class DynamicElementTextModel : public QStandardItemModel class DynamicElementTextModel : public QStandardItemModel
{ {
Q_OBJECT Q_OBJECT
public: public:
enum ValueType { enum ValueType {
textFrom =1, textFrom =1,
@ -58,10 +60,10 @@ class DynamicElementTextModel : public QStandardItemModel
grpHoldBottom, grpHoldBottom,
grpFrame grpFrame
}; };
DynamicElementTextModel(Element *element, QObject *parent = nullptr); DynamicElementTextModel(Element *element, QObject *parent = nullptr);
~DynamicElementTextModel() override; ~DynamicElementTextModel() override;
bool indexIsInGroup(const QModelIndex &index) const; bool indexIsInGroup(const QModelIndex &index) const;
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const; DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
DynamicElementTextItem *textFromItem(QStandardItem *item) const; DynamicElementTextItem *textFromItem(QStandardItem *item) const;
@ -72,13 +74,13 @@ class DynamicElementTextModel : public QStandardItemModel
QUndoCommand *undoForEditedGroup( QUndoCommand *undoForEditedGroup(
ElementTextItemGroup *group, ElementTextItemGroup *group,
QUndoCommand *parent_undo = nullptr) const; QUndoCommand *parent_undo = nullptr) const;
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const; ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
ElementTextItemGroup *groupFromItem(QStandardItem *item) const; ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
QModelIndex indexFromGroup(ElementTextItemGroup *group) const; QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
bool indexIsText(const QModelIndex &index) const; bool indexIsText(const QModelIndex &index) const;
bool indexIsGroup(const QModelIndex &index) const; bool indexIsGroup(const QModelIndex &index) const;
bool canDropMimeData( bool canDropMimeData(
const QMimeData *data, const QMimeData *data,
Qt::DropAction action, Qt::DropAction action,
@ -93,10 +95,10 @@ class DynamicElementTextModel : public QStandardItemModel
const QModelIndex &parent) override; const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override; QMimeData *mimeData(const QModelIndexList &indexes) const override;
QStringList mimeTypes() const override; QStringList mimeTypes() const override;
signals: signals:
void dataChanged(); void dataChanged();
private: private:
QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti); QList<QStandardItem *> itemsForText(DynamicElementTextItem *deti);
void addText(DynamicElementTextItem *deti); void addText(DynamicElementTextItem *deti);
@ -119,7 +121,7 @@ class DynamicElementTextModel : public QStandardItemModel
DynamicElementTextModel::ValueType type); DynamicElementTextModel::ValueType type);
void updateDataFromGroup(ElementTextItemGroup *group, void updateDataFromGroup(ElementTextItemGroup *group,
DynamicElementTextModel::ValueType type); DynamicElementTextModel::ValueType type);
private: private:
QPointer<Element> m_element; QPointer<Element> m_element;
QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list; QHash <DynamicElementTextItem *, QStandardItem *> m_texts_list;
@ -134,10 +136,10 @@ class DynamicElementTextModel : public QStandardItemModel
class DynamicTextItemDelegate : public QStyledItemDelegate class DynamicTextItemDelegate : public QStyledItemDelegate
{ {
Q_OBJECT Q_OBJECT
public: public:
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR); DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
QWidget *createEditor( QWidget *createEditor(
QWidget *parent, QWidget *parent,
const QStyleOptionViewItem &option, const QStyleOptionViewItem &option,
@ -146,10 +148,10 @@ class DynamicTextItemDelegate : public QStyledItemDelegate
QWidget *editor, QWidget *editor,
QAbstractItemModel *model, QAbstractItemModel *model,
const QModelIndex &index) const override; const QModelIndex &index) const override;
protected: protected:
bool eventFilter(QObject *object, QEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override;
private: private:
QStringList availableInfo(DynamicElementTextItem *deti) const; QStringList availableInfo(DynamicElementTextItem *deti) const;
}; };

View File

@ -18,6 +18,8 @@
#ifndef LINKSINGLEELEMENTWIDGET_H #ifndef LINKSINGLEELEMENTWIDGET_H
#define LINKSINGLEELEMENTWIDGET_H #define LINKSINGLEELEMENTWIDGET_H
#include <QHash>
#include "element.h" #include "element.h"
#include "abstractelementpropertieseditorwidget.h" #include "abstractelementpropertieseditorwidget.h"
@ -73,30 +75,30 @@ class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
void hideButtons(); void hideButtons();
void showButtons(); void showButtons();
void headerCustomContextMenuRequested(const QPoint &pos); void headerCustomContextMenuRequested(const QPoint &pos);
void on_m_unlink_pb_clicked(); void on_m_unlink_pb_clicked();
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_m_tree_widget_customContextMenuRequested(const QPoint &pos); void on_m_tree_widget_customContextMenuRequested(const QPoint &pos);
void on_m_show_linked_pb_clicked(); void on_m_show_linked_pb_clicked();
void on_m_show_this_pb_clicked(); void on_m_show_this_pb_clicked();
void on_m_search_field_textEdited(const QString &arg1); void on_m_search_field_textEdited(const QString &arg1);
private: private:
Ui::LinkSingleElementWidget *ui; Ui::LinkSingleElementWidget *ui;
bool m_unlink = false; bool m_unlink = false;
Element::kind m_filter; Element::kind 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;
QTreeWidgetItem *m_qtwi_at_context_menu = nullptr, QTreeWidgetItem *m_qtwi_at_context_menu = nullptr,
*m_pending_qtwi = nullptr; *m_pending_qtwi = nullptr;
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;
QAction *m_link_action, QAction *m_link_action,
*m_show_qtwi, *m_show_qtwi,

View File

@ -20,6 +20,7 @@
#include <QWidget> #include <QWidget>
#include <QHash> #include <QHash>
#include "abstractelementpropertieseditorwidget.h" #include "abstractelementpropertieseditorwidget.h"
class Element; class Element;

View File

@ -15,13 +15,16 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QSettings>
#include <QHash>
#include "multipastedialog.h" #include "multipastedialog.h"
#include "ui_multipastedialog.h" #include "ui_multipastedialog.h"
#include "diagram.h" #include "diagram.h"
#include "diagramcommands.h" #include "diagramcommands.h"
#include "element.h" #include "element.h"
#include "conductorautonumerotation.h" #include "conductorautonumerotation.h"
#include <QSettings>
MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) : MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -29,16 +32,16 @@ MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
m_diagram(diagram) m_diagram(diagram)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->m_x_sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview); 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_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); connect(ui->m_copy_count, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
QRectF br; QRectF br;
for (QGraphicsItem *item : m_diagram->selectedItems()) for (QGraphicsItem *item : m_diagram->selectedItems())
br = br.united(item->mapToScene(item->boundingRect()).boundingRect()); br = br.united(item->mapToScene(item->boundingRect()).boundingRect());
m_origin = br.topLeft(); m_origin = br.topLeft();
m_document = m_diagram->toXml(false); m_document = m_diagram->toXml(false);
updatePreview(); updatePreview();
} }
@ -56,7 +59,7 @@ MultiPasteDialog::~MultiPasteDialog()
} }
} }
} }
delete ui; delete ui;
} }
@ -73,20 +76,20 @@ void MultiPasteDialog::updatePreview()
} }
m_pasted_content.clear(); m_pasted_content.clear();
m_pasted_content_list.clear(); m_pasted_content_list.clear();
QPointF offset(ui->m_x_sb->value(), ui->m_y_sb->value()); QPointF offset(ui->m_x_sb->value(), ui->m_y_sb->value());
QPointF pos = m_origin+offset; QPointF pos = m_origin+offset;
for(int i=0 ; i<ui->m_copy_count->value() ; i++) for(int i=0 ; i<ui->m_copy_count->value() ; i++)
{ {
DiagramContent dc; DiagramContent dc;
m_diagram->fromXml(m_document, pos, false, &dc); m_diagram->fromXml(m_document, pos, false, &dc);
m_pasted_content += dc; m_pasted_content += dc;
m_pasted_content_list << dc; m_pasted_content_list << dc;
pos += offset; pos += offset;
} }
if(m_pasted_content.count()) if(m_pasted_content.count())
m_diagram->adjustSceneRect(); m_diagram->adjustSceneRect();
} }
@ -96,7 +99,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
if(m_pasted_content.count()) if(m_pasted_content.count())
{ {
m_diagram->undoStack().beginMacro(tr("Multi-collage")); m_diagram->undoStack().beginMacro(tr("Multi-collage"));
QSettings settings; QSettings settings;
bool erase_label = settings.value("diagramcommands/erase-label-on-copy", true).toBool(); 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. //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) //and so the auto_num below do nothing (there is not a formula to compare)
if(ui->m_auto_num_cb->isChecked()) if(ui->m_auto_num_cb->isChecked())
settings.setValue("diagramcommands/erase-label-on-copy", false); settings.setValue("diagramcommands/erase-label-on-copy", false);
m_diagram->clearSelection(); m_diagram->clearSelection();
m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, m_pasted_content)); m_diagram->undoStack().push(new PasteDiagramCommand(m_diagram, m_pasted_content));
for(DiagramContent dc : m_pasted_content_list) for(DiagramContent dc : m_pasted_content_list)
{ {
QList<Element *> pasted_elements = dc.m_elements; QList<Element *> pasted_elements = dc.m_elements;
//Sort the list element by there pos (top -> bottom) //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());}); std::sort(pasted_elements.begin(), pasted_elements.end(), [](Element *a, Element *b){return (a->pos().y() < b->pos().y());});
//Auto-connection //Auto-connection
if(ui->m_auto_connection_cb->isChecked()) if(ui->m_auto_connection_cb->isChecked())
{ {
@ -125,10 +128,10 @@ void MultiPasteDialog::on_m_button_box_accepted()
while (!elmt->AlignedFreeTerminals().isEmpty()) while (!elmt->AlignedFreeTerminals().isEmpty())
{ {
QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst(); QPair <Terminal *, Terminal *> pair = elmt->AlignedFreeTerminals().takeFirst();
Conductor *conductor = new Conductor(pair.first, pair.second); Conductor *conductor = new Conductor(pair.first, pair.second);
m_diagram->undoStack().push(new AddItemCommand<Conductor *>(conductor, m_diagram, QPointF())); 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 //Autonum the new conductor, the undo command associated for this, have for parent undo_object
ConductorAutoNumerotation can (conductor, m_diagram); ConductorAutoNumerotation can (conductor, m_diagram);
can.numerate(); can.numerate();
@ -138,7 +141,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
} }
} }
} }
//Set up the label of element //Set up the label of element
//Instead of use the current autonum of project, //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 //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(); QHash <QString, NumerotationContext> autonums = m_diagram->project()->elementAutoNum();
QHashIterator<QString, NumerotationContext> hash_iterator(autonums); QHashIterator<QString, NumerotationContext> hash_iterator(autonums);
while(hash_iterator.hasNext()) while(hash_iterator.hasNext())
{ {
hash_iterator.next(); 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. //Like elements, we compare formula of pasted conductor with the autonums available in the project.
if(ui->m_auto_num_cond_cb->isChecked()) if(ui->m_auto_num_cond_cb->isChecked())
{ {
//This list is to ensure we not numerate twice the same conductor //This list is to ensure we not numerate twice the same conductor
QList<Conductor *> numerated; QList<Conductor *> numerated;
//Start with the element at top //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(); QHash <QString, NumerotationContext> autonums = m_diagram->project()->conductorAutoNum();
QHashIterator <QString, NumerotationContext> hash_iterator(autonums); QHashIterator <QString, NumerotationContext> hash_iterator(autonums);
while (hash_iterator.hasNext()) while (hash_iterator.hasNext())
{ {
hash_iterator.next(); hash_iterator.next();
@ -205,7 +208,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
} }
} }
} }
m_diagram->adjustSceneRect(); m_diagram->adjustSceneRect();
m_accept = true; m_accept = true;
settings.setValue("diagramcommands/erase-label-on-copy", erase_label); settings.setValue("diagramcommands/erase-label-on-copy", erase_label);

View File

@ -15,11 +15,14 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QRadioButton>
#include <QHash>
#include "potentialselectordialog.h" #include "potentialselectordialog.h"
#include "ui_potentialselectordialog.h" #include "ui_potentialselectordialog.h"
#include "conductor.h" #include "conductor.h"
#include "terminal.h" #include "terminal.h"
#include <QRadioButton>
#include "QPropertyUndoCommand/qpropertyundocommand.h" #include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "diagram.h" #include "diagram.h"
#include "element.h" #include "element.h"
@ -191,14 +194,14 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
} else if (list.size() == 1) { } else if (list.size() == 1) {
return list.first(); return list.first();
} }
QDialog dialog(widget); QDialog dialog(widget);
QVBoxLayout layout(widget); QVBoxLayout layout(widget);
dialog.setLayout(&layout); dialog.setLayout(&layout);
QLabel label(tr("Veuillez choisir un potentiel électrique de la liste \n" QLabel label(tr("Veuillez choisir un potentiel électrique de la liste \n"
"à utiliser pour le nouveau potentiel")); "à utiliser pour le nouveau potentiel"));
layout.addWidget(&label); layout.addWidget(&label);
QHash <QRadioButton *, ConductorProperties> H; QHash <QRadioButton *, ConductorProperties> H;
for (ConductorProperties cp : list) for (ConductorProperties cp : list)
{ {
@ -213,7 +216,7 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
text.append(tr("\nCouleur du conducteur : %1").arg(cp.m_wire_color)); text.append(tr("\nCouleur du conducteur : %1").arg(cp.m_wire_color));
if(!cp.m_wire_section.isEmpty()) if(!cp.m_wire_section.isEmpty())
text.append(tr("\nSection du conducteur : %1").arg(cp.m_wire_section)); text.append(tr("\nSection du conducteur : %1").arg(cp.m_wire_section));
QRadioButton *b = new QRadioButton(text, &dialog); QRadioButton *b = new QRadioButton(text, &dialog);
layout.addWidget(b); layout.addWidget(b);
H.insert(b, cp); H.insert(b, cp);
@ -221,14 +224,14 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList<ConductorPro
QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok, &dialog); QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok, &dialog);
layout.addWidget(button_box); layout.addWidget(button_box);
connect(button_box, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); connect(button_box, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
dialog.exec(); dialog.exec();
for (QRadioButton *b : H.keys()) { for (QRadioButton *b : H.keys()) {
if(b->isChecked()) { if(b->isChecked()) {
return H.value(b); return H.value(b);
} }
} }
return ConductorProperties(); return ConductorProperties();
} }
@ -290,7 +293,7 @@ void PotentialSelectorDialog::buildWidget()
QString text1(tr("%n conducteurs composent le potentiel suivant :", QString text1(tr("%n conducteurs composent le potentiel suivant :",
"", "",
m_potential_selector->m_conductor_number_1)); m_potential_selector->m_conductor_number_1));
ConductorProperties cp1; ConductorProperties cp1;
if(!m_potential_selector->m_properties_list_1.isEmpty()) if(!m_potential_selector->m_properties_list_1.isEmpty())
cp1 = m_potential_selector->m_properties_list_1.first();; cp1 = m_potential_selector->m_properties_list_1.first();;
@ -308,14 +311,14 @@ void PotentialSelectorDialog::buildWidget()
if(!cp1.m_wire_section.isEmpty()) if(!cp1.m_wire_section.isEmpty())
text1.append(tr("\nSection du conducteur : %1") text1.append(tr("\nSection du conducteur : %1")
.arg(cp1.m_wire_section)); .arg(cp1.m_wire_section));
QString text2(tr("%n conducteurs composent le potentiel suivant :", QString text2(tr("%n conducteurs composent le potentiel suivant :",
"", "",
m_potential_selector->m_conductor_number_2)); m_potential_selector->m_conductor_number_2));
ConductorProperties cp2; ConductorProperties cp2;
if(!m_potential_selector->m_properties_list_2.isEmpty()) if(!m_potential_selector->m_properties_list_2.isEmpty())
cp2 = m_potential_selector->m_properties_list_2.first(); cp2 = m_potential_selector->m_properties_list_2.first();
if(!cp2.text.isEmpty()) if(!cp2.text.isEmpty())
text2.append(tr("\nNuméro : %1").arg(cp2.text)); text2.append(tr("\nNuméro : %1").arg(cp2.text));
if(!cp2.m_function.isEmpty()) if(!cp2.m_function.isEmpty())
@ -329,7 +332,7 @@ void PotentialSelectorDialog::buildWidget()
if(!cp2.m_wire_section.isEmpty()) if(!cp2.m_wire_section.isEmpty())
text2.append(tr("\nSection du conducteur : %1") text2.append(tr("\nSection du conducteur : %1")
.arg(cp2.m_wire_section)); .arg(cp2.m_wire_section));
QRadioButton *rb1 = new QRadioButton(text1, this); QRadioButton *rb1 = new QRadioButton(text1, this);
QRadioButton *rb2 = new QRadioButton(text2, this); QRadioButton *rb2 = new QRadioButton(text2, this);
@ -429,7 +432,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
new_value, new_value,
undo); undo);
} }
//Check if formula of the new potential //Check if formula of the new potential
// have incompatible variable with folio report // have incompatible variable with folio report
QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM"); QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
@ -445,7 +448,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
<< "%F" << "%F"
<< "%M" << "%M"
<< "%LM"; << "%LM";
QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n" QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n"
"Veuillez saisir une formule compatible pour ce potentiel.\n" "Veuillez saisir une formule compatible pour ce potentiel.\n"
"Les variables suivantes sont incompatibles :\n" "Les variables suivantes sont incompatibles :\n"
@ -455,7 +458,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
fag.setText(text); fag.setText(text);
fag.setFormula(cp.m_formula); fag.setFormula(cp.m_formula);
fag.exec(); fag.exec();
QString new_formula = fag.formula(); QString new_formula = fag.formula();
QSet <Conductor *> c_list = m_report->conductors().first()->relatedPotentialConductors(); QSet <Conductor *> c_list = m_report->conductors().first()->relatedPotentialConductors();
c_list.insert(m_report->conductors().first()); c_list.insert(m_report->conductors().first());
@ -471,7 +474,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
new_value, new_value,
undo); undo);
} }
break; break;
} }
} }

View File

@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QHash>
#include "shapegraphicsitempropertieswidget.h" #include "shapegraphicsitempropertieswidget.h"
#include "ui_shapegraphicsitempropertieswidget.h" #include "ui_shapegraphicsitempropertieswidget.h"
#include "qetshapeitem.h" #include "qetshapeitem.h"

View File

@ -15,12 +15,14 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "xrefpropertieswidget.h"
#include <utility> #include <utility>
#include <QHash>
#include <QMetaEnum>
#include "xrefpropertieswidget.h"
#include "ui_xrefpropertieswidget.h" #include "ui_xrefpropertieswidget.h"
#include "qdebug.h" #include "qdebug.h"
#include <QMetaEnum>
/** /**
@brief XRefPropertiesWidget::XRefPropertiesWidget @brief XRefPropertiesWidget::XRefPropertiesWidget

View File

@ -19,6 +19,8 @@
#define XREFPROPERTIESWIDGET_H #define XREFPROPERTIESWIDGET_H
#include <QWidget> #include <QWidget>
#include <QHash>
#include "properties/xrefproperties.h" #include "properties/xrefproperties.h"
namespace Ui { namespace Ui {

View File

@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -21,6 +21,7 @@
#include <QUndoCommand> #include <QUndoCommand>
#include <QPointer> #include <QPointer>
#include <QDomElement> #include <QDomElement>
#include <QHash>
class Element; class Element;
class DynamicElementTextItem; class DynamicElementTextItem;
@ -37,10 +38,10 @@ class AddElementTextCommand : public QUndoCommand
DynamicElementTextItem *deti, DynamicElementTextItem *deti,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
~AddElementTextCommand() override; ~AddElementTextCommand() override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
Element *m_element = nullptr; Element *m_element = nullptr;
DynamicElementTextItem *m_text = nullptr; DynamicElementTextItem *m_text = nullptr;
@ -64,10 +65,10 @@ class AddTextsGroupCommand : public QUndoCommand
QList<DynamicElementTextItem *> texts_list, QList<DynamicElementTextItem *> texts_list,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
~AddTextsGroupCommand() override; ~AddTextsGroupCommand() override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QPointer<Element> m_element; QPointer<Element> m_element;
QPointer<ElementTextItemGroup> m_group; QPointer<ElementTextItemGroup> m_group;
@ -88,10 +89,10 @@ class RemoveTextsGroupCommand : public QUndoCommand
ElementTextItemGroup *group, ElementTextItemGroup *group,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
~RemoveTextsGroupCommand() override; ~RemoveTextsGroupCommand() override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QPointer<Element> m_element; QPointer<Element> m_element;
QPointer<ElementTextItemGroup> m_group; QPointer<ElementTextItemGroup> m_group;
@ -108,10 +109,10 @@ class AddTextToGroupCommand : public QUndoCommand
ElementTextItemGroup *group, ElementTextItemGroup *group,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
~AddTextToGroupCommand() override; ~AddTextToGroupCommand() override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QPointer<DynamicElementTextItem> m_text; QPointer<DynamicElementTextItem> m_text;
QPointer<ElementTextItemGroup> m_group; QPointer<ElementTextItemGroup> m_group;
@ -128,10 +129,10 @@ class RemoveTextFromGroupCommand : public QUndoCommand
ElementTextItemGroup *group, ElementTextItemGroup *group,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
~RemoveTextFromGroupCommand() override; ~RemoveTextFromGroupCommand() override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QPointer<DynamicElementTextItem> m_text; QPointer<DynamicElementTextItem> m_text;
QPointer<ElementTextItemGroup> m_group; QPointer<ElementTextItemGroup> m_group;
@ -148,12 +149,12 @@ class AlignmentTextsGroupCommand : public QUndoCommand
Qt::Alignment new_alignment, Qt::Alignment new_alignment,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
~AlignmentTextsGroupCommand() override; ~AlignmentTextsGroupCommand() override;
int id() const override{return 6;} int id() const override{return 6;}
bool mergeWith(const QUndoCommand *other) override; bool mergeWith(const QUndoCommand *other) override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QPointer<ElementTextItemGroup> m_group; QPointer<ElementTextItemGroup> m_group;
Qt::Alignment m_previous_alignment, Qt::Alignment m_previous_alignment,

View File

@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -19,6 +19,8 @@
#define DELETEQGRAPHICSITEMCOMMAND_H #define DELETEQGRAPHICSITEMCOMMAND_H
#include <QUndoCommand> #include <QUndoCommand>
#include <QHash>
#include "diagramcontent.h" #include "diagramcontent.h"
class Diagram; class Diagram;
@ -32,17 +34,17 @@ class DeleteQGraphicsItemCommand : public QUndoCommand
public: public:
DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr); DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr);
~DeleteQGraphicsItemCommand() override; ~DeleteQGraphicsItemCommand() override;
private: private:
DeleteQGraphicsItemCommand(const DeleteQGraphicsItemCommand &); DeleteQGraphicsItemCommand(const DeleteQGraphicsItemCommand &);
void setPotentialsOfRemovedElements(); void setPotentialsOfRemovedElements();
Terminal *terminalInSamePotential(Terminal *terminal, Conductor *conductor_to_exclude); Terminal *terminalInSamePotential(Terminal *terminal, Conductor *conductor_to_exclude);
public: public:
void undo() override; void undo() override;
void redo() override; void redo() override;
// attributes // attributes
private: private:
DiagramContent m_removed_contents; DiagramContent m_removed_contents;

View File

@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -20,6 +20,7 @@
#include <QUndoCommand> #include <QUndoCommand>
#include <QPointer> #include <QPointer>
#include <QHash>
class Diagram; class Diagram;
class ConductorTextItem; class ConductorTextItem;
@ -35,16 +36,16 @@ class RotateSelectionCommand : public QUndoCommand
RotateSelectionCommand(Diagram *diagram, qreal angle=90, QUndoCommand *parent=nullptr); RotateSelectionCommand(Diagram *diagram, qreal angle=90, QUndoCommand *parent=nullptr);
void undo() override; void undo() override;
void redo() override; void redo() override;
bool isValid(); bool isValid();
private: private:
Diagram *m_diagram =nullptr; Diagram *m_diagram =nullptr;
QList<QPointer<ConductorTextItem>> m_cond_text; QList<QPointer<ConductorTextItem>> m_cond_text;
QHash<ConductorTextItem *, bool> m_rotate_by_user; QHash<ConductorTextItem *, bool> m_rotate_by_user;
QList<QPropertyUndoCommand*> m_undo; QList<QPropertyUndoCommand*> m_undo;
}; };
#endif // ROTATESELECTIONCOMMAND_H #endif // ROTATESELECTIONCOMMAND_H

View File

@ -20,6 +20,7 @@
#include <QUndoCommand> #include <QUndoCommand>
#include <QPointer> #include <QPointer>
#include <QHash>
class ConductorTextItem; class ConductorTextItem;
class Diagram; class Diagram;
@ -34,14 +35,14 @@ class RotateTextsCommand : public QUndoCommand
{ {
public: public:
RotateTextsCommand(Diagram *diagram, QUndoCommand *parent=nullptr); RotateTextsCommand(Diagram *diagram, QUndoCommand *parent=nullptr);
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
void openDialog(); void openDialog();
void setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end); void setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end);
private: private:
QPointer<Diagram> m_diagram; QPointer<Diagram> m_diagram;
QHash<ConductorTextItem *, bool> m_cond_texts; QHash<ConductorTextItem *, bool> m_cond_texts;