diff --git a/lang/qet_de.qm b/lang/qet_de.qm
index 77a5bf4e0..c7ee9ec00 100644
Binary files a/lang/qet_de.qm and b/lang/qet_de.qm differ
diff --git a/lang/qet_de.ts b/lang/qet_de.ts
index 74a0dda0f..75f61ebd6 100644
--- a/lang/qet_de.ts
+++ b/lang/qet_de.ts
@@ -51,7 +51,7 @@
log
-
+ Log
@@ -63,13 +63,13 @@
Les développeurs de QElectroTechabout tab, developers line
-
+ Die Entwickler von QElectroTechContact : <a href="mailto:qet@lists.tuxfamily.org">qet@lists.tuxfamily.org</a>about tab, contact line
- Kontakt : <a href="mailto:qet@lists.tuxfamily.org">qet@lists.tuxfamily.org</a>
+ Kontakt: <a href="mailto:qet@lists.tuxfamily.org">qet@lists.tuxfamily.org</a>
@@ -103,7 +103,7 @@
Collection
- Sammlung
+ Sammlung
@@ -297,99 +297,99 @@
Ajouter un tableau
-
+ Tabelle einfügenAffichage
- Anzeige
+ AnzeigeAjuster la taille du tableau au folio
-
+ Tabellegröße an Folie anpassenAjouter de nouveau folio et tableau si nécessaire.
-
+ Neue Folie und Tabelle hinzufügen wenn erforderlich.Nom du tableau
-
+ Name der TabelleTexte des en-têtes
-
+ TabellenkopfGauche
- Linksbündig
+ LinksbündigCentre
- Zentriert
+ ZentriertDroite
- Rechtsbündig
+ RechtsbündigPolice :
- Schriftart:
+ Schriftart:Éditer
- Bearbeiten
+ BearbeitenMarges :
-
+ Ränder:Alignement :
- Ausrichtung:
+ Ausrichtung:Texte du tableau
-
+ TabelleninhaltConfiguration
- Einstellung
+ KonfigurationContenu
-
+ InhaltSélectionner la police des en tête du tableau
-
+ Schriftart für Tabellenkopf auswählenSélectionner la police des cellules du tableau
-
+ Schriftart für Tabellentext auswählen
@@ -580,7 +580,7 @@
Built
- As-Built
+ wie gefertigt
@@ -610,27 +610,28 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Dialog
- Dialog
+ DialogMise en page
- Einrichtung
+ Seitenlayoutinclure les en-têtes
-
+ Überschriften einschließenFormater en tant que liste de materiel
-
+ als Stückliste
+ nomenclature_
- Stückliste_
+ Betriebsmittelverzeichnis_
@@ -664,13 +665,13 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Position du folio
- Folienreihenfolge
+ Position der FolieQuantité numéro d'articleSpecial field with name : designation quantity
-
+ Menge Artikelnummer
@@ -841,7 +842,7 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Formule du texte :
- Formel vom Text:
+ Textformel:
@@ -867,7 +868,7 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Section du conducteur
-
+ Leiterabschnitt
@@ -913,7 +914,7 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Taille :
- Größe:
+ Größe:
@@ -939,7 +940,7 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Couleur du texte:
-
+ Textfarbe:
@@ -964,7 +965,7 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Taille de trait :
- Größe:
+ Linienstärke:
@@ -1017,12 +1018,12 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
GroupBox
-
+ Configuration
- Einstellung
+ Einstellungen
@@ -1870,7 +1871,7 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Simple
- Einfach
+ Einzelbauteil
@@ -1979,14 +1980,14 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Type : %1
- Typ: %1
+ Typ: %1
Sous-type : %1
-
+ Subtyp: %1
@@ -2039,157 +2040,157 @@ Bemerkung: diese Optionen verhindern NICHT das automatische Nummerieren.
Form
-
+ Informations disponibles
- Verfügbare Informationen
+ Verfügbare InformationenInformations à exporter
- Zu exportierende Informationen
+ Zu exportierende InformationenMonter la sélection
- Auswahl nach oben verschieben
+ Auswahl nach oben verschiebenAjouter la sélection
- Auswahl hinzufügen
+ Auswahl einfügenSupprimer la sélection
-
+ Auswahl löschenDescendre la sélection
- Auswahl nach unten verschieben
+ Auswahl nach unten verschiebenPas de filtre
-
+ Kein FilterN'est pas vide
-
+ Ist nicht leerEst vide
-
+ Ist leerContient
-
+ EnthältNe contient pas
-
+ Enthält nichtEst égal à
-
+ Ist gleichN'est pas égale à
-
+ UngleichFiltre :
-
+ Filter:Type d'éléments
- Bauteiltyp
+ BauteiltypenSimples
- Einfache
+ EinzelbauteileTous
- Alle
+ AlleContacteurs et relais
- Schütze und Relais
+ Schütze und RelaisBoutons et commutateurs
- Bedienelemente
+ Tasten und SchalterBorniers
- Klemmleisten
+ KlemmleistenOrganes de protection
- Schutzeinrichtungen
+ SchutzeinrichtungenConfiguration
- Einstellung
+ KonfigurationOuvrir la configuration sélectionné
- Ausgewählte Konfiguration öffnen
+ Ausgewählte Konfiguration öffnenSauvegarder la configuration actuelle
- Aktuelle Konfiguration speichern
+ Aktuelle Konfiguration speichernRequête SQL personnalisée
- Personalisierte SQL-Anfrage
+ Benutzerdefinierte SQL-AbfrageRequête SQL :
- SQL-Anfrage:
+ SQL-Abfrage:Position
-
+ PositionTitre du folio
- Folientitel
+ FolientitelPosition du folio
- Folienreihenfolge
+ Position der FolieNuméro du folio
-
+ Foliennummer
@@ -2561,7 +2562,7 @@ Alle Bauteile und Unterordner von diesem Ordner werden ebenso gelöscht.
Ajouter un folio
- Neue Folie einfügen
+ Neue Folie hinzufügen
@@ -2586,7 +2587,7 @@ Alle Bauteile und Unterordner von diesem Ordner werden ebenso gelöscht.
Remonter ce folio au debut
- Folie zum Anfang verschieben
+ Folie an den Anfang verschieben
@@ -2667,7 +2668,7 @@ Alle Bauteile und Unterordner von diesem Ordner werden ebenso gelöscht.
Exporter les folios du projetwindow title
- Folien vom Projekt exportieren
+ Folien des Projekts exportieren
@@ -3037,7 +3038,7 @@ Texte und Zahlen sind ebenso erlaubt.
Utiliser les numéros de folio à la place de leur position dans le projet
- Foliennummer verwenden anstelle von Reihenfolgenindex im Projekt
+ Foliennummer anstelle von Reihenfolgenindex im Projekt verwenden
@@ -3076,7 +3077,7 @@ Hier unten kann der Standardwert dieses Textfeldes für Ihre eigenen Bauteile de
Exporter les bornes dans la nomenclature
- Klemmen in die Stückliste exportieren
+ Klemmen in Betriebsmittelverzeichnis exportieren
@@ -3316,7 +3317,7 @@ Hier unten kann der Standardwert dieses Textfeldes für Ihre eigenen Bauteile de
Japonais
-
+ Japanisch
@@ -3351,7 +3352,7 @@ Hier unten kann der Standardwert dieses Textfeldes für Ihre eigenen Bauteile de
Norvege
-
+ Norwegisch
@@ -3381,7 +3382,7 @@ Hier unten kann der Standardwert dieses Textfeldes für Ihre eigenen Bauteile de
Ceci est un projet QElectroTech, c'est-à-dire un fichier d'extension .qet regroupant plusieurs folios. Il embarque également les éléments et modèles de cartouches utilisés dans ces folios."What's this" tip
- Das ist ein QElectroTech-Projekt : eine *.qet Datei, in der Folien, eingebettete Bauteile und eingebettete Zeichnungsköpfe gespeichert sind.
+ Das ist ein QElectroTech-Projekt: eine *.qet Datei, in der Folien, eingebettete Bauteile und eingebettete Zeichnungsköpfe gespeichert sind.
@@ -3424,185 +3425,187 @@ Hier unten kann der Standardwert dieses Textfeldes für Ihre eigenen Bauteile de
Form
-
+ Affichage
- Anzeige
+ DarstellungNom du tableau
-
+ Name der TabelleAucun
-
+ KeineToutes
-
+ AllesLignes à afficher :
-
+ Anzuzeigende Zeilen:Y :
- y:
+ y:Tableau suivant
-
+ Nächste TabelleX :
- x:
+ x:Tableau précédent
-
+ Vorherige TabelleTableau précédent :
-
+ Vorherige Tabelle:Géometrie et lignes
-
+ Geometrie und LinienAppliquer la géometrie à tous les tableaux liée à celui-ci
-
+ Geometrie auf alle hiermit verknüpften Tabellen anwendenAjuster le tableau au folio
-
+ Tabelle an Foliegröße anpassenTextLabel
- TextLabel
+ TextLabelEn tête
-
+ KopfzeileMarge
-
+ RandAligement :
-
+ Ausrichtung:Gauche
- Linksbündig
+ LinksbündigCentré
- Mittig
+ ZentriertDroite
- Rechtsbündig
+ RechtsbündigPolice
- Schiftart
+ SchriftartTableau
-
+ TabelleninhaltAlignement :
- Ausrichtung:
+ Ausrichtung:Contenu
-
+ InhaltDéplacer un tableau
-
+ Tabelle verschiebenModifier le nombre de ligne affiché par un tableau
-
+ Anzahl der angezeigten Zeilen einer Tabelle ändernModifier les marges d'une en tête de tableau
-
+ Ränder des Tabellenkopfs ändernModifier les marges d'un tableau
-
+ Ränder der Tabelle ändernModifier l'alignement d'une en tête de tableau
-
+ Textausrichtung eines Tabellenkopfs ändernModifier l'alignement des textes d'un tableau
-
+ Textausrichtung in einer Tabelle ändernModifier la police d'une en tête de tableau
-
+ Schriftart eines Tabellenkopfs ändernChanger la police d'un tableau
-
+ Schriftart einer Tabelle ändern<center>ATTENTION :</center>
il manque %1 lignes afin d'afficher l'intégralité des informations
-
+ <center>ACHTUNG:</center>
+ %1 Zeilen fehlen, um alle Information darzustellenAppliquer la géometrie d'un tableau aux tableau liée à celui-ci
-
+ Geometrie einer Tabelle auf alle damit verknüpften Tabellen anwenden
+
@@ -4018,13 +4021,13 @@ Veuillez utiliser l'éditeur avancé pour cela.
Couleur du conducteur
- Leiterfarbe
+ LeiterfarbeSection du conducteur
-
+ Leiterabschnitt
@@ -4077,12 +4080,12 @@ Veuillez utiliser l'éditeur avancé pour cela.
Compilation :
- Kompiliert:
+ Kompiliert: Compilation :
-
+
@@ -4090,27 +4093,27 @@ Veuillez utiliser l'éditeur avancé pour cela.
Editer les marges
-
+ Ränder ändernHaut :
-
+ Oben:Gauche :
-
+ Links:Droit :
-
+ Rechts:Bas :
-
+ Unten:
@@ -4751,7 +4754,8 @@ Nummer: %1
Couleur du conducteur : %1
-
+
+Farbe des Leiters: %1
@@ -4759,7 +4763,8 @@ Couleur du conducteur : %1
Section du conducteur : %1
-
+
+Querschnitt des Leiters: %1
@@ -4850,12 +4855,12 @@ Folgende Variablen sind inkompatibel:
Position
-
+ PositionPosition du folio
- Folienreihenfolge
+ Position der Folie
@@ -4863,17 +4868,17 @@ Folgende Variablen sind inkompatibel:
Form
-
+ Requête
-
+ Datenauswahl ändernRecharger
- Neu laden
+ Daten neu laden
@@ -4983,22 +4988,22 @@ Voulez-vous enregistrer les modifications ?
Nettoyer le projetwindow title
- Projekt reinigen
+ Projekt bereinigenAjouter un folio
- Neue Folie einfügen
+ Neue Folie hinzufügenRevenir au debut du projet
-
+ Aller à la fin du projet
-
+
@@ -5032,19 +5037,19 @@ Voulez-vous enregistrer les modifications ?
Chargement... Initialisation du cache des collections d'élémentssplash screen caption
- Lade... Initialisiere die Bauteilsammlungen
+ Laden... Initialisiere die BauteilsammlungenChargement... Éditeur de schémasplash screen caption
- Lade... Schaltplaneditor
+ Laden... SchaltplaneditorChargement... Ouverture des fichierssplash screen caption
- Lade... Öffne Dateien
+ Laden... Öffne Dateien
@@ -5059,12 +5064,12 @@ Voulez-vous enregistrer les modifications ?
Couleur du fil
-
+ DrahtfarbeSection du fil
-
+ Drahtabschnitt
@@ -5110,7 +5115,7 @@ Voulez-vous enregistrer les modifications ?
LTRTranslate this string to RTL if you are translating to a Right-to-Left language, else translate to LTR
- LTR
+ LTR
@@ -5183,29 +5188,29 @@ Voulez-vous enregistrer les modifications ?
Indice de révision
- Revisionsindex
+ RevisionsindexDate
- Datum
+ DatumPosition
-
+ PositionCartouches QETtitle of the title block templates collection provided by QElectroTech
- QET-Zeichnungsköpfe
+ QET-ZeichnungsköpfeCartouches utilisateurtitle of the user's title block templates collection
- Benutzer-Zeichnungsköpfe
+ Benutzer-Zeichnungsköpfe
@@ -5540,7 +5545,7 @@ Verfügbare Optionen:
Ajouter un folio
- Neue Folie einfügen
+ Neue Folie hinzufügen
@@ -5550,7 +5555,7 @@ Verfügbare Optionen:
Ajouter une nomenclature
-
+ Betriebsmittelverzeichnis einfügen
@@ -5695,7 +5700,7 @@ Verfügbare Optionen:
Nettoyer le projet
- Projekt reinigen
+ Projekt bereinigen
@@ -6021,7 +6026,7 @@ Verfügbare Optionen:
Exporter la base de donnée interne du projet
-
+
@@ -6044,12 +6049,12 @@ Verfügbare Optionen:
SPACE
-
+ Ctrl+SPACE
-
+
@@ -6211,7 +6216,7 @@ Verfügbare Optionen:
Place les éléments du presse-papier sur le foliostatus bar tip
- Fügt den Inhalt der Zwischenablage auf die Folio ein
+ Inhalt der Zwischenablage auf Folie einfügen
@@ -6415,12 +6420,12 @@ Verfügbare Optionen:
un fichier
- eine Datei
+ einer Dateiun élément
- ein Bauteil
+ einem Bauteil
@@ -7255,7 +7260,7 @@ les conditions requises ne sont pas valides
Adapter le folio à la page
- Passt die Folie an die Blattgröße an
+ Folie an Blattgröße anpassen
@@ -7980,7 +7985,7 @@ Que désirez vous faire ?
%n tableau(s)part of a sentence listing the content of diagram
-
+
@@ -8377,7 +8382,7 @@ Que désirez vous faire ?
Position du folio
- Folienreihenfolge
+ Position der Folie
@@ -8541,7 +8546,7 @@ Möchten Sie sie ersetzen?Chercher/remplacer les propriétés de folio
- Folieneigenschaften suchen/ersetzen
+ Folienneigenschaften suchen/ersetzen
@@ -8591,7 +8596,7 @@ Möchten Sie sie ersetzen?
Nombre de folio
- Folienanzahl
+ Anzahl der Folien
@@ -8651,32 +8656,32 @@ Möchten Sie sie ersetzen?
To install the plugin qet_tb_generator<br>Visit :<br><a href='https://pypi.python.org/pypi/qet-tb-generator'>qet-tb-generator</a><br><br>Requires python 3.5 or above.<br><br><B><U> First install on Linux</B></U><br>1. check you have pip3 installed: pip3 --version<br>If not install with: sudo apt-get install python3-pip<br>2. Install the program: sudo pip3 install qet_tb_generator<br>3. Run the program: qet_tb_generator<br><br><B><U> Update on Linux</B></U><br>sudo pip3 install --upgrade qet_tb_generator<br>
-
+ Error launching qet_tb_generator plugin
- Fehler beim Ausführen vom Plugin qet_tb_generator
+ Fehler beim Ausführen vom Plugin qet_tb_generatorTo install the plugin qet_tb_generator<br>Visit :<br><a href='https://pypi.python.org/pypi/qet-tb-generator'>qet-tb-generator</a><br><B><U> First install on macOSX</B></U><br>1. Install, if required, python 3.8 bundle only, because program use hardcoded PATH for localise qet-tb-generator plugin <br> Visit :<br><a href='https://qelectrotech.org/forum/viewtopic.php?pid=5674#p5674'>howto</a><br>2. pip3 install qet_tb_generator<br><B><U> Update on macOSX</B></U><br> pip3 install --upgrade qet_tb_generator<br>
-
+ So installieren Sie das Plugin qet_tb_generator <br> Besuchen Sie: <br> <a href='https://pypi.python.org/pypi/qet-tb-generator'> qet-tb-generator </a> <br> < B> <U> Zuerst unter macOSX </ B> </ U> <br> 1 installieren. Installieren Sie bei Bedarf nur das Python 3.8-Bundle, da das Programm den fest codierten PATH zum Lokalisieren des qet-tb-generator-Plugins verwendet. <br> Besuchen Sie: <br> <a href = 'https: //qelectrotech.org/forum/viewtopic.php? pid = 5674 # p5674 '> Howto </a> <br> 2. pip3 install qet_tb_generator <br> <B> <U> Update unter macOSX </ B> </ U> <br> pip3 install - Upgrade qet_tb_generator <br>Ajouter une nomenclature
-
+ Betriebsmittelverzeichnis einfügenAjouter un sommaire
- Inhaltsverzeichnis einfügen
+ Inhaltsverzeichnis einfügenColler
-
+ Einfügen
@@ -8700,23 +8705,25 @@ Möchten Sie sie ersetzen?
Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par les tableaux.
Veuillez ajouter un nouveau tableau ou regler les tableaux existant afin d'afficher l'integralité des informations.
-
+ Die anzuzeigenden Informationen sind größer als die maximale Menge, die von den Tabellen angezeigt werden kann.
+Bitte fügen Sie eine neue Tabelle hinzu oder passen Sie die vorhandenen Tabellen an, um alle Informationen anzuzeigen.Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par le tableau.
Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'afficher l'integralité des informations.
-
+ Die anzuzeigenden Informationen sind größer als die maximale Menge, die von der Tabelle angezeigt werden kann.
+Bitte fügen Sie eine neue Tabelle hinzu oder passen Sie die vorhandene Tabelle an, um alle Informationen anzuzeigen.Limitation de tableau
-
+ TabellenbeschränkungModifier la géometrie d'un tableau
-
+ Tabellengeometrie ändern
@@ -8896,7 +8903,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Texte sur conducteur horizontal :
- Text auf waagerechtem Leiter
+ Text auf waagerechtem Leiter:
@@ -8919,7 +8926,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Formule du texte :
- Formel vom Text:
+ Textformel:
@@ -8935,7 +8942,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Texte sur conducteur vertical :
- Text auf senkrechtem Leiter
+ Text auf senkrechtem Leiter:
@@ -8960,7 +8967,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Couleur du conducteur
- Leiterfarbe
+ Farbe des Leiters
@@ -8971,7 +8978,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Section du conducteur
-
+ Leiterabschnitt
@@ -9128,7 +9135,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Fichier :
- Datei
+ Datei:
@@ -9155,17 +9162,17 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Auteur :
- Bearbeiter
+ Bearbeiter:Date :
- Datum
+ Datum:Installation :
- Anlage
+ Anlage:
@@ -9180,7 +9187,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Folio :
- Folie
+ Folie:
@@ -9195,7 +9202,7 @@ Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'af
Date fixe :
- Festes Datum:
+ Festes Datum:
@@ -9216,9 +9223,9 @@ Les variables suivantes sont utilisables :
- %autonum : Folio Auto Numeration
Für Zeichnungskopf-Vorlagen als %folio verfügbar.
Folgende Variablen stehen im Feld Folie zur Verfügung:
-%id: aktuelle Foliennummer
-%total: gesamte Folienanzahl
-%autonum: aktuelle Foliennummer (generiert durch Nummerierungsregel)
+%id: Blattnummer der aktuellen Folie im Projekt
+%total: Anzahl aller Folien im Projekt
+%autonum: Folie lt. Folien-Auto-Nummerierung
@@ -9228,7 +9235,7 @@ Folgende Variablen stehen im Feld Folie zur Verfügung:
Titre :
- Titel
+ Titel:
@@ -9278,7 +9285,7 @@ Créer votre propre texte en vous aidant des variables suivantes :
%c : le numéro de colonne
Sie können eigene Querverweistexte definieren.
Folgende Variablen sind verfügbar:
-%f: Reihenfolge der Folie im Projekt
+%f: Position der Folie im Projekt
%F: Foliennummer
%M: Anlage
%LM: Ort
@@ -9431,7 +9438,7 @@ Folgende Variablen sind verfügbar:
Eléments simple
- Einfache Bauteile
+ Einzelbauteile
@@ -9620,10 +9627,10 @@ Vorangestellte Nullen werden hinzugefügt falls der Startwert vom Feld "Wer
- Der Typ "Text" steht für einen fixen Text.
In diesem Fall wird das Feld "Inkrementierung" ignoriert.
-- Der Typ "Foliennummer" steht für die Position der Folie im Projekt (Reihenfolge).
+- Der Typ "Foliennummer" steht für die Pos-Nr. der Folie im Projekt (Reihenfolge).
Andere Felder werden nicht verwendet.
-- Der Typ "Folie" steht für die Folienummer.
+- Der Typ "Folie" steht für die Nummernangabe in der jeweiligen Folie.
Andere Felder werden nicht verwendet.
@@ -9932,7 +9939,7 @@ Andere Felder werden nicht verwendet.
Pink : MediumVioletRedelement part color
-
+ Rosa: Mediumvioletred
@@ -11774,7 +11781,7 @@ Andere Felder werden nicht verwendet.
Épaisseur :
-
+ Stärke:
@@ -11817,27 +11824,27 @@ Andere Felder werden nicht verwendet.
Informations disponibles
- Verfügbare Informationen
+ Verfügbare InformationenInformation à afficher
-
+ Anzuzeigende InformationenConfiguration
- Einstellung
+ KonfigurationRequête SQL :
- SQL-Anfrage:
+ SQL-Abfrage:Position
-
+ Position
@@ -12117,9 +12124,9 @@ Les variables suivantes sont utilisables :
- %autonum : Folio Auto Numeration
Für Zeichnungskopf-Vorlagen als %folio verfügbar.
Folgende Variablen stehen im Feld Folie zur Verfügung:
-%id: aktuelle Foliennummer
-%total: gesamte Folienanzahl
-%autonum: aktuelle Foliennummer (generiert durch Nummerierungsregel)
+%id: Blattnummer im Projekt
+%total: Anzahl aller Blätter im Projekt
+%autonum: Folien-Auto-Nummerierung
@@ -12154,7 +12161,7 @@ Folgende Variablen stehen im Feld Folie zur Verfügung:
Page Num:
- Nummerierung:
+ Auto-Nummerierung:
@@ -12337,7 +12344,7 @@ die Variable "volta" kombiniert mit dem Wert "1745" lässt i
Par défaut, les variables suivantes sont disponibles :<ul><li>%{author} : auteur du folio</li><li>%{date} : date du folio</li><li>%{title} : titre du folio</li><li>%{filename} : nom de fichier du projet</li><li>%{plant} : nom de l'installation (=) dans laquelle se trouve le folio</li><li>%{locmach} : nom de la localisation (+) dans laquelle se trouve le folio</li><li>%{indexrev} : indice de révision du folio</li><li>%{version} : version du logiciel</li><li>%{folio} : numéro du folio</li><li>%{folio-id} : position du folio dans le projet</li><li>%{folio-total} : nombre total de folios dans le projet</li><li>%{previous-folio-num} : numéro du folio précédent</li><li>%{next-folio-num} : numéro du folio suivant</li><li>%{projecttitle} : titre du projet</li><li>%{projectpath} : chemin du projet</li><li>%{projectfilename} : nom du fichier</li><li>%{saveddate} : date d'enregistrement du fichier</li><li>%{savedtime} : heure d'enregistrement du fichier</li><li>%{savedfilename} : nom du fichier enregistré</li><li>%{savedfilepath} : chemin du fichier enregistré</li></ul>
- Standardmäßig sind folgende Variablen verfügbar:<ul><li>%{author}: Bearbeiter</li><li>%{date}: Datum</li><li>%{title}: Folientitel</li><li>%{filename}: Dateiname vom Projekt</li><li>%{plant}: Anlage (=), bezogen auf Folie</li><li>%{locmach}: Ort (+), bezogen auf Folie</li><li>%{indexrev}: Revisionsindex</li><li>%{version}: Softwareversion</li><li>%{folio}: Foliennummer</li><li>%{folio-id}: Position der Folie im Projekt</li><li>%{folio-total}: gesamte Folienanzahl im Projekt</li><li>%{previous-folio-num}: vorherige Foliennummer</li><li>%{next-folio-num}: nächste Foliennummer</li><li>%{projecttitle}: Projekttitel</li><li>%{projectpath}: Pfad zur Projektdatei</li><li>%{projectfilename}: Dateiname</li><li>%{saveddate}: letztes Datum vom Abspeichern des Projekts</li><li>%{savedtime}: letzte Uhrzeit vom Abspeichern des Projekts</li><li>%{savedfilename}: abgespeicherte Dateiname</li><li>%{savedfilepath}: abgespeicherter Pfad zur Datei</li></ul>
+ Standardmäßig sind folgende Variablen verfügbar:<ul><li>%{author}: Bearbeiter</li><li>%{date}: Datum</li><li>%{title}: Folientitel</li><li>%{filename}: Dateiname vom Projekt</li><li>%{plant}: Anlage (=), bezogen auf Folie</li><li>%{locmach}: Ort (+), bezogen auf Folie</li><li>%{indexrev}: Revisionsindex</li><li>%{version}: Softwareversion</li><li>%{folio}: Foliennummer</li><li>%{folio-id}: Position der Folie im Projekt</li><li>%{folio-total}: Anzahl der Folien im Projekt</li><li>%{previous-folio-num}: vorherige Foliennummer</li><li>%{next-folio-num}: nächste Foliennummer</li><li>%{projecttitle}: Projekttitel</li><li>%{projectpath}: Pfad zur Projektdatei</li><li>%{projectfilename}: Dateiname</li><li>%{saveddate}: letztes Datum vom Abspeichern des Projekts</li><li>%{savedtime}: letzte Uhrzeit vom Abspeichern des Projekts</li><li>%{savedfilename}: abgespeicherte Dateiname</li><li>%{savedfilepath}: abgespeicherter Pfad zur Datei</li></ul>
@@ -12899,13 +12906,13 @@ Maximale Länge: %2px
Unstable file format!
-
+ <p><b>ATTENTION: This application version is UNSTABLE!</b></p><p>Everything you do with this application can break your workspace, libraries or projects! Saved files will not be readable with stable releases of QElectroTech. It's highly recommended to create a backup before proceeding. If you are unsure, please download an official stable release instead.</p><p>Are you really sure to continue with the risk of breaking your files?!</p>this text is not finished yet, expect changes!
-
+ <p> <b> ACHTUNG: Diese Anwendungsversion ist NICHT STABIL! </ b> </ p> <p> Alles, was Sie mit dieser Anwendung tun, kann Ihren Arbeitsbereich, Ihre Bibliotheken oder Projekte beschädigen! Gespeicherte Dateien können mit stabilen Versionen von QElectroTech nicht gelesen werden. Es wird dringend empfohlen, ein Backup zu erstellen, bevor Sie fortfahren. Wenn Sie sich nicht sicher sind, laden Sie stattdessen eine offizielle stabile Version herunter. </ P> <p> Sind Sie wirklich sicher, dass Sie mit dem Risiko Ihre Dateien zu beschädigen fortfahren wollen?! </ P>
@@ -12913,12 +12920,12 @@ Maximale Länge: %2px
Exporter la base de données interne du projet
-
+ Interne Projekt-Datenbank exportierensans_nom
-
+ unbenannt
diff --git a/qelectrotech.pro b/qelectrotech.pro
index b28366496..1972e200a 100644
--- a/qelectrotech.pro
+++ b/qelectrotech.pro
@@ -76,6 +76,7 @@ include(sources/QWidgetAnimation/QWidgetAnimation.pri)
DEFINES += QAPPLICATION_CLASS=QApplication
DEFINES += QT_MESSAGELOGCONTEXT
DEFINES += GIT_COMMIT_SHA="\\\"$(shell git -C \""$$_PRO_FILE_PWD_"\" rev-parse --verify HEAD)\\\""
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
TEMPLATE = app
DEPENDPATH += .
diff --git a/sources/ElementsCollection/elementscollectionmodel.h b/sources/ElementsCollection/elementscollectionmodel.h
index ba3541084..beb86ab9a 100644
--- a/sources/ElementsCollection/elementscollectionmodel.h
+++ b/sources/ElementsCollection/elementscollectionmodel.h
@@ -19,6 +19,7 @@
#define ELEMENTSCOLLECTIONMODEL2_H
#include
+#include
#include "elementslocation.h"
class XmlProjectElementCollectionItem;
diff --git a/sources/ElementsCollection/elementslocation.cpp b/sources/ElementsCollection/elementslocation.cpp
index cd09896e4..1fe3d90c7 100644
--- a/sources/ElementsCollection/elementslocation.cpp
+++ b/sources/ElementsCollection/elementslocation.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
diff --git a/sources/NameList/ui/namelistwidget.h b/sources/NameList/ui/namelistwidget.h
index 2bd30f531..45074c980 100644
--- a/sources/NameList/ui/namelistwidget.h
+++ b/sources/NameList/ui/namelistwidget.h
@@ -1,25 +1,27 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#ifndef NAMELISTWIDGET_H
#define NAMELISTWIDGET_H
-#include "nameslist.h"
#include
+#include
+
+#include "nameslist.h"
namespace Ui {
class NameListWidget;
@@ -32,27 +34,27 @@ namespace Ui {
class NameListWidget : public QWidget
{
Q_OBJECT
-
+
public:
explicit NameListWidget(QWidget *parent = nullptr);
~NameListWidget();
-
+
void addLine();
void setNames (const NamesList &name_list);
NamesList names() const;
void setReadOnly(bool ro);
bool isEmpty() const;
void setClipboardValue (QHash value);
-
+
private slots:
void on_m_clipboard_cb_activated(int index);
-
+
private:
void clean();
-
+
private:
Ui::NameListWidget *ui;
- bool m_read_only = false;
+ bool m_read_only = false;
};
#endif // NAMELISTWIDGET_H
diff --git a/sources/QetGraphicsItemModeler/qetgraphicshandlerutility.h b/sources/QetGraphicsItemModeler/qetgraphicshandlerutility.h
index 59527ca2b..6e226fda3 100644
--- a/sources/QetGraphicsItemModeler/qetgraphicshandlerutility.h
+++ b/sources/QetGraphicsItemModeler/qetgraphicshandlerutility.h
@@ -20,7 +20,6 @@
#include
#include
-#include
#include
class QPainter;
diff --git a/sources/autoNum/numerotationcontext.cpp b/sources/autoNum/numerotationcontext.cpp
index 1f932e9fa..a94fe7ec9 100644
--- a/sources/autoNum/numerotationcontext.cpp
+++ b/sources/autoNum/numerotationcontext.cpp
@@ -16,9 +16,10 @@
along with QElectroTech. If not, see .
*/
#include "numerotationcontext.h"
+#include "qet.h"
#include
-#include "qet.h"
+#include
/**
Constructor
@@ -141,7 +142,7 @@ QString NumerotationContext::validRegExpNumber() const
*/
bool NumerotationContext::keyIsAcceptable(const QString &type) const
{
- return (type.contains(QRegExp(validRegExpNum())));
+ return (type.contains(QRegularExpression(validRegExpNum())));
}
/**
@@ -150,7 +151,7 @@ bool NumerotationContext::keyIsAcceptable(const QString &type) const
*/
bool NumerotationContext::keyIsNumber(const QString &type) const
{
- return (type.contains(QRegExp(validRegExpNumber())));
+ return (type.contains(QRegularExpression(validRegExpNumber())));
}
/**
diff --git a/sources/autoNum/ui/numparteditorw.cpp b/sources/autoNum/ui/numparteditorw.cpp
index 7e4e3ae80..2ab28f366 100644
--- a/sources/autoNum/ui/numparteditorw.cpp
+++ b/sources/autoNum/ui/numparteditorw.cpp
@@ -1,21 +1,20 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
-#include
#include "numparteditorw.h"
#include "ui_numparteditorw.h"
diff --git a/sources/bordertitleblock.cpp b/sources/bordertitleblock.cpp
index 9f230cc63..026bab62f 100644
--- a/sources/bordertitleblock.cpp
+++ b/sources/bordertitleblock.cpp
@@ -1,22 +1,24 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#include
#include
+#include
+
#include "titleblocktemplate.h"
#include "titleblocktemplaterenderer.h"
#include "bordertitleblock.h"
@@ -49,18 +51,19 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
// at first, the internal titleblock template renderer uses the default titleblock template
m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
-
+
// disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
- if (!QRegExp("4\\.[0-7]\\.").exactMatch(qVersion())) {
- m_titleblock_template_renderer -> setUseCache(false);
- }
-
+#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) // ### Qt 6: remove
+#else
+ m_titleblock_template_renderer -> setUseCache(false);
+#endif
+
// dimensions par defaut du schema
importBorder(BorderProperties());
-
+
// contenu par defaut du cartouche
importTitleBlock(TitleBlockProperties());
-
+
display_titleblock_ = true;
display_border_ = true;
setFolioData(1, 1);
@@ -227,11 +230,11 @@ void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
xml_elmt.setAttribute("cols", columnsCount());
xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
-
+
xml_elmt.setAttribute("rows", rowsCount());
xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
-
+
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
}
@@ -246,18 +249,18 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
// columns count
int cols_count = xml_elmt.attribute("cols").toInt(&ok);
if (ok) setColumnsCount(cols_count);
-
+
// columns width
double cols_width = xml_elmt.attribute("colsize").toDouble(&ok);
if (ok) setColumnsWidth(cols_width);
-
+
// backward compatibility:
// diagrams saved with 0.1 version have a "height" attribute
if (xml_elmt.hasAttribute("rows") && xml_elmt.hasAttribute("rowsize")) {
// rows counts
int rows_count = xml_elmt.attribute("rows").toInt(&ok);
if (ok) setRowsCount(rows_count);
-
+
// taille des lignes
double rows_size = xml_elmt.attribute("rowsize").toDouble(&ok);
if (ok) setRowsHeight(rows_size);
@@ -266,7 +269,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
double height = xml_elmt.attribute("height").toDouble(&ok);
if (ok) setDiagramHeight(height);
}
-
+
// rows and columns display
displayColumns(xml_elmt.attribute("displaycols") != "false");
displayRows(xml_elmt.attribute("displayrows") != "false");
@@ -282,7 +285,7 @@ void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
TitleBlockProperties BorderTitleBlock::exportTitleBlock()
{
TitleBlockProperties ip;
-
+
ip.author = author();
ip.date = date();
ip.title = title();
@@ -297,7 +300,7 @@ TitleBlockProperties BorderTitleBlock::exportTitleBlock()
ip.auto_page_num = autoPageNum();
ip.context = additional_fields_;
ip.collection = QET::QetCollection::Embedded;
-
+
return(ip);
}
@@ -322,7 +325,7 @@ void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
emit(displayChanged());
}
additional_fields_ = ip.context;
-
+
emit(needFolioData()); // Note: we expect additional data to be provided
// through setFolioData(),
// which in turn calls updateDiagramContextForTitleBlock().
@@ -422,7 +425,7 @@ void BorderTitleBlock::titleBlockTemplateRemoved(
const QString &removed_template_name,
const TitleBlockTemplate *new_template) {
if (titleBlockTemplateName() != removed_template_name) return;
-
+
if (new_template) {
setTitleBlockTemplate(new_template);
} else {
@@ -516,14 +519,14 @@ void BorderTitleBlock::draw(QPainter *painter)
pen.setCosmetic(true);
painter -> setPen(pen);
painter -> setBrush(Qt::NoBrush);
-
+
QSettings settings;
-
+
//Draw the borer
if (display_border_) painter -> drawRect(diagram_rect_);
-
+
painter -> setFont(QETApp::diagramTextsFont());
-
+
//Draw the empty case at the top left of diagram when there is header
if (display_border_ && (display_columns_ || display_rows_))
{
@@ -535,7 +538,7 @@ void BorderTitleBlock::draw(QPainter *painter)
);
painter -> drawRect(first_rectangle);
}
-
+
//Draw the nums of columns
if (display_border_ && display_columns_) {
for (int i = 1 ; i <= columns_count_ ; ++ i) {
@@ -561,7 +564,7 @@ void BorderTitleBlock::draw(QPainter *painter)
}
}
}
-
+
//Draw the nums of rows
if (display_border_ && display_rows_) {
QString row_string("A");
@@ -584,7 +587,7 @@ void BorderTitleBlock::draw(QPainter *painter)
row_string = incrementLetters(row_string);
}
}
-
+
// render the titleblock, using the TitleBlockTemplate object
if (display_titleblock_) {
QRectF tbt_rect = titleBlockRectForQPainter();
@@ -607,7 +610,7 @@ void BorderTitleBlock::draw(QPainter *painter)
painter -> translate(-tbt_rect.topLeft());
}
}
-
+
painter -> restore();
}
@@ -646,18 +649,18 @@ void BorderTitleBlock::drawDxf(
}
QSettings settings;
-
+
// draw the numbering of the columns
// dessine la numerotation des colonnes
if (display_border_ &&
display_columns_) {
- int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
+ int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
for (int i = 1 ; i <= columns_count_ ; ++ i) {
- double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
+ double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
(rows_header_width_ + ((i - 1) *
columns_width_));
double yCoord = Createdxf::sheetHeight
- - diagram_rect_.topLeft().y()*Createdxf::yScale
+ - diagram_rect_.topLeft().y()*Createdxf::yScale
- columns_header_height_;
double recWidth = columns_width_;
double recHeight = columns_header_height_;
@@ -665,18 +668,18 @@ void BorderTitleBlock::drawDxf(
recWidth, recHeight, color);
Createdxf::drawTextAligned(file_path,
- QString::number(i + offset),
- xCoord+recWidth/4,
- yCoord + recHeight*0.5,
+ QString::number(i + offset),
+ xCoord+recWidth/4,
+ yCoord + recHeight*0.5,
recHeight*0.7,
0,
0,
1,
2,
- xCoord+recWidth/2,
- 1,
+ xCoord+recWidth/2,
+ 1,
color);
- }
+ }
}
// draw line numbering
@@ -686,8 +689,8 @@ void BorderTitleBlock::drawDxf(
for (int i = 1 ; i <= rows_count_ ; ++ i) {
double xCoord = diagram_rect_.topLeft().x()
* Createdxf::xScale;
- double yCoord = Createdxf::sheetHeight
- - diagram_rect_.topLeft().y()
+ double yCoord = Createdxf::sheetHeight
+ - diagram_rect_.topLeft().y()
*Createdxf::yScale
- (
columns_header_height_
@@ -700,15 +703,15 @@ void BorderTitleBlock::drawDxf(
recWidth, recHeight, color);
Createdxf::drawTextAligned(file_path,
row_string,
- xCoord+recWidth*0.1,
- yCoord + recHeight*0.4,
+ xCoord+recWidth*0.1,
+ yCoord + recHeight*0.4,
recWidth*0.7,
0,
0,
1,
2,
xCoord+recWidth/2,
- 1,
+ 1,
color);
row_string = incrementLetters(row_string);
}
@@ -869,11 +872,11 @@ DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos)
QPointF relative_pos = pos - insideBorderRect().topLeft();
int row_number = int(ceil(relative_pos.x() / columnsWidth()));
int column_number = int(ceil(relative_pos.y() / rowsHeight()));
-
+
QString letter = "A";
for (int i = 1 ; i < column_number ; ++ i)
letter = incrementLetters(letter);
-
+
return(DiagramPosition(letter, row_number));
}
@@ -931,11 +934,14 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
foreach (QString key, additional_fields_.keys()) {
context.addValue(key, additional_fields_[key]);
}
-
+
// ... overridden by the historical and/or dynamically generated fields
+ QLocale var;
+ var.dateFormat(QLocale::ShortFormat);
context.addValue("author", btb_author_);
- context.addValue("date", btb_date_.toString(
- Qt::SystemLocaleShortDate));
+ context.addValue(
+ "date",
+ QLocale::system().toString(btb_date_, QLocale::ShortFormat));
context.addValue("title", btb_title_);
context.addValue("filename", btb_filename_);
context.addValue("plant", btb_plant_);
@@ -948,7 +954,7 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
context.addValue("auto_page_num", btb_auto_page_num_);
context.addValue("previous-folio-num", m_previous_folio_num);
context.addValue("next-folio-num", m_next_folio_num);
-
+
m_titleblock_template_renderer -> setContext(context);
}
@@ -1000,12 +1006,12 @@ void BorderTitleBlock::setFolioData(
const QString& autonum,
const DiagramContext &project_properties) {
if (index < 1 || total < 1 || index > total) return;
-
+
// memorize information
// memorise les informations
folio_index_ = index;
folio_total_ = total;
-
+
// regenerate the content of the folio field
// regenere le contenu du champ folio
btb_final_folio_ = btb_folio_;
diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp
index 0377c103f..4d368e6b8 100644
--- a/sources/conductorproperties.cpp
+++ b/sources/conductorproperties.cpp
@@ -1,24 +1,24 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#include "conductorproperties.h"
#include
#include
-
+#include
/**
Constructeur par defaut
*/
@@ -70,7 +70,7 @@ void SingleLineProperties::draw(QPainter *painter,
const QRectF &rect) {
// s'il n'y a rien a dessiner, on retourne immediatement
if (!hasNeutral && !hasGround && !phases) return;
-
+
// prepare le QPainter
painter -> save();
QPen pen(painter -> pen());
@@ -80,12 +80,12 @@ void SingleLineProperties::draw(QPainter *painter,
pen.setWidthF(1);
painter -> setPen(pen);
painter -> setRenderHint(QPainter::Antialiasing, true);
-
+
uint symbols_count = (hasNeutral ? 1 : 0) + (hasGround ? 1 : 0) - (isPen() ? 1 : 0) + phases;
qreal interleave_base = (direction == QET::Horizontal ? rect.width() : rect.height());
qreal interleave = interleave_base / (symbols_count + 1);;
qreal symbol_width = interleave_base / 12;
-
+
for (uint i = 1 ; i <= symbols_count ; ++ i) {
// dessine le tronc du symbole
QPointF symbol_p1, symbol_p2;
@@ -97,7 +97,7 @@ void SingleLineProperties::draw(QPainter *painter,
symbol_p1 = QPointF(rect.x() + rect.width() * 0.25, rect.y() + (i * interleave) + symbol_width);
}
painter -> drawLine(QLineF(symbol_p1, symbol_p2));
-
+
// dessine le reste des symboles terre et neutre
if (isPen()) {
if (i == 1) {
@@ -126,13 +126,13 @@ void SingleLineProperties::drawGround(QPainter *painter,
QPointF center,
qreal size) {
painter -> save();
-
+
// prepare le QPainter
painter -> setRenderHint(QPainter::Antialiasing, false);
QPen pen2(painter -> pen());
pen2.setCapStyle(Qt::SquareCap);
painter -> setPen(pen2);
-
+
// dessine le segment representant la terre
qreal half_size = size / 2.0;
QPointF offset_point(
@@ -145,7 +145,7 @@ void SingleLineProperties::drawGround(QPainter *painter,
center - offset_point
)
);
-
+
painter -> restore();
}
@@ -161,11 +161,11 @@ void SingleLineProperties::drawNeutral(
qreal size)
{
painter -> save();
-
+
// prepare le QPainter
if (painter -> brush() == Qt::NoBrush) painter -> setBrush(Qt::black);
painter -> setPen(Qt::NoPen);
-
+
// desine le cercle representant le neutre
painter -> drawEllipse(
QRectF(
@@ -173,7 +173,7 @@ void SingleLineProperties::drawNeutral(
QSizeF(size, size)
)
);
-
+
painter -> restore();
}
@@ -192,7 +192,7 @@ void SingleLineProperties::drawPen(QPainter *painter,
QPointF center,
qreal size) {
painter -> save();
-
+
//painter -> setBrush(Qt::white);
// desine le cercle representant le neutre
//painter -> drawEllipse(
@@ -202,7 +202,7 @@ void SingleLineProperties::drawPen(QPainter *painter,
// )
//);
drawNeutral(painter, center, size * 1.5);
-
+
int offset = (size * 1.5 / 2.0);
QPointF pos = center + (direction == QET::Horizontal ? QPointF(0.0, -offset - 0.5) : QPointF(offset + 0.5, 0.0));
drawGround(painter, direction, pos, 2.0 * size);
@@ -271,11 +271,11 @@ void ConductorProperties::toXml(QDomElement &e) const
if (color != QColor(Qt::black))
e.setAttribute("color", color.name());
-
+
e.setAttribute("bicolor", m_bicolor? "true" : "false");
e.setAttribute("color2", m_color_2.name());
e.setAttribute("dash-size", QString::number(m_dash_size));
-
+
if (type == Single)
singleLineProperties.toXml(e);
@@ -292,11 +292,11 @@ void ConductorProperties::toXml(QDomElement &e) const
e.setAttribute("onetextperfolio", m_one_text_per_folio);
e.setAttribute("vertirotatetext", QString::number(verti_rotate_text));
e.setAttribute("horizrotatetext", QString::number(horiz_rotate_text));
-
+
QMetaEnum me = QMetaEnum::fromType();
e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
-
+
QString conductor_style = writeStyle();
if (!conductor_style.isEmpty())
e.setAttribute("style", conductor_style);
@@ -316,15 +316,15 @@ void ConductorProperties::fromXml(QDomElement &e)
QString bicolor_str = e.attribute("bicolor", "false");
m_bicolor = bicolor_str == "true"? true : false;
-
+
QColor xml_color_2 = QColor(e.attribute("color2"));
m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
-
+
m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
-
+
// read style of conductor
readStyle(e.attribute("style"));
-
+
if (e.attribute("type") == typeToString(Single))
{
// get specific properties for single conductor
@@ -349,7 +349,7 @@ void ConductorProperties::fromXml(QDomElement &e)
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
-
+
QMetaEnum me = QMetaEnum::fromType();
m_horizontal_alignment = Qt::Alignment(
me.keyToValue(
@@ -396,7 +396,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
-
+
QMetaEnum me = QMetaEnum::fromType();
settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
@@ -412,13 +412,13 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
{
QColor settings_color = QColor(settings.value(prefix + "color").toString());
color = (settings_color.isValid()? settings_color : QColor(Qt::black));
-
+
QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
-
+
m_bicolor = settings.value(prefix + "bicolor", false).toBool();
m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
-
+
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
type = (setting_type == typeToString(Single)? Single : Multi);
@@ -438,11 +438,11 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
-
+
QMetaEnum me = QMetaEnum::fromType();
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
-
+
readStyle(settings.value(prefix + "style").toString());
}
@@ -468,7 +468,7 @@ QString ConductorProperties::typeToString(ConductorType t)
void ConductorProperties::applyForEqualAttributes(QList list)
{
const QList clist = std::move(list);
-
+
if (clist.isEmpty())
return;
@@ -505,7 +505,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis
int i_value;
double d_value;
Qt::Alignment align_value;
-
+
//Color
c_value = clist.first().color;
for(ConductorProperties cp : clist)
@@ -516,7 +516,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis
if (equal)
color = c_value;
equal = true;
-
+
//bicolor
b_value = clist.first().m_bicolor;
for(ConductorProperties cp : clist)
@@ -527,7 +527,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis
if (equal)
m_bicolor = b_value;
equal = true;
-
+
//second color
c_value = clist.first().m_color_2;
for(ConductorProperties cp : clist)
@@ -538,7 +538,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis
if (equal)
m_color_2 = c_value;
equal = true;
-
+
//Dash size
i_value = clist.first().m_dash_size;
for(ConductorProperties cp : clist)
@@ -693,7 +693,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis
if (equal)
horiz_rotate_text = d_value;
equal = true;
-
+
//Text alignment for horizontal conducor
align_value = clist.first().m_horizontal_alignment;
for(ConductorProperties cp : clist)
@@ -704,7 +704,7 @@ void ConductorProperties::applyForEqualAttributes(QList lis
if (equal)
m_horizontal_alignment = align_value;
equal = true;
-
+
//Text alignment for vertical conducor
align_value = clist.first().m_vertical_alignment;
for(ConductorProperties cp : clist)
@@ -778,9 +778,9 @@ bool ConductorProperties::operator!=(const ConductorProperties &other) const{
*/
void ConductorProperties::readStyle(const QString &style_string) {
style = Qt::SolidLine; // style par defaut
-
+
if (style_string.isEmpty()) return;
-
+
// recupere la liste des couples style / valeur
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
@@ -788,12 +788,13 @@ void ConductorProperties::readStyle(const QString &style_string) {
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
#endif
-
- QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
+
+ QRegularExpression Rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
foreach (QString style_str, styles) {
- if (rx.exactMatch(style_str)) {
- QString style_name = rx.cap(1);
- QString style_value = rx.cap(2);
+ if (Rx==QRegularExpression(style_str)) {
+
+ QString style_name = Rx.namedCaptureGroups().at(1);
+ QString style_value = Rx.namedCaptureGroups().at(2);
if (style_name == "line-style") {
if (style_value == "dashed") style = Qt::DashLine;
else if (style_value == "dashdotted") style = Qt::DashDotLine;
diff --git a/sources/configpages.cpp b/sources/configpages.cpp
index 573c9c94d..caa5101e6 100644
--- a/sources/configpages.cpp
+++ b/sources/configpages.cpp
@@ -1,20 +1,26 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
+
+#include
+#include
+#include
+#include
+
#include "configpages.h"
#include "borderpropertieswidget.h"
#include "conductorpropertieswidget.h"
@@ -27,10 +33,7 @@
#include "qetproject.h"
#include "reportproperties.h"
#include "qetapp.h"
-#include
-#include
-#include
-#include
+#include "nameslist.h"
/**
@brief NewDiagramPage::NewDiagramPage
@@ -249,13 +252,13 @@ void NewDiagramPage::loadSavedTbp()
ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export
epw = new ExportPropertiesWidget(ExportProperties::defaultExportProperties());
-
+
// layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout *vlayout1 = new QVBoxLayout();
-
+
QLabel *title = new QLabel(this -> title());
vlayout1 -> addWidget(title);
-
+
QFrame *horiz_line = new QFrame();
horiz_line -> setFrameShape(QFrame::HLine);
vlayout1 -> addWidget(horiz_line);
@@ -300,13 +303,13 @@ PrintConfigPage::PrintConfigPage(QWidget *parent) : ConfigPage(parent) {
// epw contient les options d'export
epw = new ExportPropertiesWidget(ExportProperties::defaultPrintProperties());
epw -> setPrintingMode(true);
-
+
// layout vertical contenant le titre, une ligne horizontale et epw
QVBoxLayout *vlayout1 = new QVBoxLayout();
-
+
QLabel *title = new QLabel(this -> title());
vlayout1 -> addWidget(title);
-
+
QFrame *horiz_line = new QFrame();
horiz_line -> setFrameShape(QFrame::HLine);
vlayout1 -> addWidget(horiz_line);
@@ -329,10 +332,10 @@ PrintConfigPage::~PrintConfigPage()
void PrintConfigPage::applyConf()
{
QString prefix = "print/default";
-
+
QSettings settings;
epw -> exportProperties().toSettings(settings, prefix);
-
+
// annule l'enregistrement de certaines proprietes non pertinentes
settings.remove(prefix + "path");
settings.remove(prefix + "format");
diff --git a/sources/createdxf.cpp b/sources/createdxf.cpp
index 98fdd63dd..6fc210268 100644
--- a/sources/createdxf.cpp
+++ b/sources/createdxf.cpp
@@ -33,7 +33,6 @@ Createdxf::Createdxf()
{
}
-
Createdxf::~Createdxf()
{
}
@@ -438,32 +437,15 @@ int Createdxf::getcolorCode (const long red, const long green, const long blue)
}
return minndx;
}
+
int Createdxf::dxfColor(QColor color) {
return Createdxf::getcolorCode(color.red(), color.green(), color.blue());
}
+
int Createdxf::dxfColor(QPen pen) {
return Createdxf::dxfColor(pen.color());
}
-/**
- @brief Createdxf::drawLine
- Conveniance function to draw line
- @param filepath
- @param line
- @param colorcode
-*/
-void Createdxf::drawLine(
- const QString &filepath,
- const QLineF &line,
- const int &colorcode)
-{
- drawLine(filepath, line.p1().x() * xScale,
- sheetHeight - (line.p1().y() * yScale),
- line.p2().x() * xScale,
- sheetHeight - (line.p2().y() * yScale),
- colorcode);
-}
-
void Createdxf::drawArcEllipse(
const QString &file_path,
qreal x,
@@ -611,26 +593,7 @@ void Createdxf::drawArcEllipse(
}
}
-/**
- @brief Createdxf::drawEllipse
- Conveniance function for draw ellipse
- @param filepath
- @param rect
- @param colorcode
-*/
-void Createdxf::drawEllipse(
- const QString &filepath,
- const QRectF &rect,
- const int &colorcode)
-{
- drawArcEllipse(
- filepath,
- rect.topLeft().x() * xScale,
- sheetHeight - (rect.topLeft().y() * yScale),
- rect.width() * xScale,
- rect.height() * yScale,
- 0, 360, 0, 0, 0, colorcode);
-}
+
/**
@brief Createdxf::drawRectangle
@@ -655,44 +618,11 @@ void Createdxf::drawRectangle (
drawPolyline(fileName,poly,colour,true);
}
-static QRectF scaleRect(QRectF rect)
-{
- QRectF ro(rect.bottomLeft().x() * Createdxf::xScale,
- Createdxf::sheetHeight - (rect.bottomLeft().y() * Createdxf::yScale),
- rect.width() * Createdxf::xScale,
- rect.height() * Createdxf::yScale);
- return ro;
-}
-/**
- @brief Createdxf::drawRectangle
- Convenience function for draw rectangle
- @param filepath
- @param rect
- @param colorcode
-*/
-void Createdxf::drawRectangle(
- const QString &filepath,
- const QRectF &rect,
- const int &colorcode) {
- QPolygonF poly(scaleRect(rect));
- drawPolyline(filepath,poly,colorcode);
-}
-/**
- @brief Createdxf::drawPolygon
- Convenience function for draw polygon
- @param filepath
- @param poly
- @param colorcode
-*/
-void Createdxf::drawPolygon(
- const QString &filepath,
- const QPolygonF &poly,
- const int &colorcode)
-{
- drawPolyline(filepath,poly,colorcode);
-}
+
+
+
/**
@brief Createdxf::drawArc
draw arc in dx format
@@ -767,7 +697,7 @@ void Createdxf::drawText(
double height,
double rotation,
int colour,
- double xScale)
+ double xScaleW)
{
if (!fileName.isEmpty()) {
QFile file(fileName);
@@ -779,7 +709,7 @@ void Createdxf::drawText(
errorFileOpen.exec();
} else {
QTextStream To_Dxf(&file);
- // Draw the circle
+ // Draw the text
To_Dxf << 0 << "\r\n";
To_Dxf << "TEXT" << "\r\n";
To_Dxf << 8 << "\r\n";
@@ -795,7 +725,7 @@ void Createdxf::drawText(
To_Dxf << 40 << "\r\n";
To_Dxf << height << "\r\n"; // Text Height
To_Dxf << 41 << "\r\n";
- To_Dxf << xScale << "\r\n"; // X Scale
+ To_Dxf << xScaleW << "\r\n"; // X Scale
To_Dxf << 1 << "\r\n";
To_Dxf << text << "\r\n"; // Text Value
To_Dxf << 50 << "\r\n";
@@ -819,7 +749,7 @@ void Createdxf::drawTextAligned(
int hAlign,
int vAlign,
double xAlign,
- double xScale,
+ double xScaleW,
int colour)
{
if (!fileName.isEmpty()) {
@@ -848,7 +778,7 @@ void Createdxf::drawTextAligned(
To_Dxf << 40 << "\r\n";
To_Dxf << height << "\r\n"; // Text Height
To_Dxf << 41 << "\r\n";
- To_Dxf << xScale << "\r\n"; // X Scale
+ To_Dxf << xScaleW << "\r\n"; // X Scale
To_Dxf << 1 << "\r\n";
To_Dxf << text << "\r\n"; // Text Value
To_Dxf << 50 << "\r\n";
@@ -961,3 +891,158 @@ void Createdxf::drawPolyline(const QString &filepath,
}
}
}
+
+/* ================================================
+ * Majority of calls above here are must be passed
+ * parameters pre=scaled to DXF units
+ * Calls below use Qt scaling, and re-scale them to DXF
+ * ================================================
+ */
+/**
+ @brief Createdxf::drawCircle
+ draw circle in qt format
+ @param fileName
+ @param center
+ @param radius
+ @param colour
+*/
+void Createdxf::drawCircle(
+ const QString& fileName,
+ QPointF centre,
+ double radius,
+ int colour)
+{
+ qreal x = centre.x() * xScale;
+ qreal y = sheetHeight - centre.y() * yScale;
+ qreal r = radius * xScale;
+ drawCircle(fileName,r,x,y,colour);
+}
+
+/**
+ @brief Createdxf::drawLine
+ Convenience function to draw line
+ @param filepath
+ @param line
+ @param colorcode
+*/
+void Createdxf::drawLine(
+ const QString &filepath,
+ const QLineF &line,
+ const int &colorcode)
+{
+ drawLine(filepath, line.p1().x() * xScale,
+ sheetHeight - (line.p1().y() * yScale),
+ line.p2().x() * xScale,
+ sheetHeight - (line.p2().y() * yScale),
+ colorcode);
+}
+
+/**
+ @brief Createdxf::drawEllipse
+ Conveniance function for draw ellipse
+ @param filepath
+ @param rect
+ @param colorcode
+*/
+void Createdxf::drawEllipse(
+ const QString &filepath,
+ const QRectF &rect,
+ const int &colorcode)
+{
+ drawArcEllipse(
+ filepath,
+ rect.topLeft().x() * xScale,
+ sheetHeight - (rect.topLeft().y() * yScale),
+ rect.width() * xScale,
+ rect.height() * yScale,
+ 0, 360, 0, 0, 0, colorcode);
+}
+
+/**
+ @brief Createdxf::drawRectangle
+ Convenience function for draw rectangle
+ @param filepath
+ @param rect
+ @param colorcode
+*/
+void Createdxf::drawRectangle(
+ const QString &filepath,
+ const QRectF &rect,
+ const int &colorcode) {
+ //QPolygonF poly(scaleRect(rect));
+ QPolygonF poly(rect);
+ drawPolyline(filepath,poly,colorcode);
+}
+
+/**
+ @brief Createdxf::drawPolygon
+ Convenience function for draw polygon
+ @param filepath
+ @param poly
+ @param colorcode
+*/
+void Createdxf::drawPolygon(
+ const QString &filepath,
+ const QPolygonF &poly,
+ const int &colorcode)
+{
+ QPolygonF pg = poly;
+ if(!poly.isClosed()) {
+ pg << poly.at(0); // Close it
+ }
+ drawPolyline(filepath,pg,colorcode);
+}
+
+/**
+ @brief Createdxf::drawText
+ draw simple text in dxf format without any alignment specified
+ @param fileName
+ @param text
+ @param point
+ @param height
+ @param rotation
+ @param colour
+ @param xScaleW=1
+*/
+void Createdxf::drawText(
+ const QString& fileName,
+ const QString& text,
+ QPointF point,
+ double height,
+ double rotation,
+ int colour,
+ double xScaleW)
+{
+ qreal x = point.x() * xScale;
+ qreal y = sheetHeight - (point.y() * yScale);
+ drawText(fileName,text,x,y,height * yScale,rotation,colour,xScaleW);
+}
+void Createdxf::drawArcEllipse(
+ const QString &file_path,
+ QRectF rect,
+ qreal startAngle,
+ qreal spanAngle,
+ QPointF hotspot,
+ qreal rotation_angle,
+ const int &colorcode)
+{
+ qreal x = rect.x() * xScale;
+ qreal y = sheetHeight - rect.y() * yScale;
+ qreal w = rect.width() * xScale;
+ qreal h = rect.height() * yScale;
+ qreal hotspot_x = hotspot.x() * xScale;
+ qreal hotspot_y = sheetHeight - hotspot.y() * yScale;
+ drawArcEllipse(file_path,x,y,w,h,startAngle,spanAngle,hotspot_x,hotspot_y,rotation_angle,colorcode);
+}
+
+/*
+ * Utility functions
+ */
+static QRectF scaleRect(QRectF rect)
+{
+ QRectF ro(rect.bottomLeft().x() * Createdxf::xScale,
+ Createdxf::sheetHeight - (rect.bottomLeft().y() * Createdxf::yScale),
+ rect.width() * Createdxf::xScale,
+ rect.height() * Createdxf::yScale);
+ return ro;
+}
diff --git a/sources/createdxf.h b/sources/createdxf.h
index 198c2892d..3d071b8f7 100644
--- a/sources/createdxf.h
+++ b/sources/createdxf.h
@@ -39,6 +39,13 @@ class Createdxf
double,
double,
int);
+
+ static void drawCircle(
+ const QString& ,
+ QPointF,
+ double,
+ int );
+
static void drawArc(
const QString&,
double x,
@@ -62,6 +69,15 @@ class Createdxf
qreal rotation_angle,
const int &colorcode);
+ static void drawArcEllipse(
+ const QString &file_path,
+ QRectF rect,
+ qreal startAngle,
+ qreal spanAngle,
+ QPointF hotspot,
+ qreal rotation_angle,
+ const int &colorcode);
+
static void drawEllipse (const QString &filepath,
const QRectF &rect,
const int &colorcode);
@@ -103,6 +119,14 @@ class Createdxf
double,
int,
double xScale=1.0);
+ static void drawText(
+ const QString&,
+ const QString&,
+ QPointF,
+ double,
+ double,
+ int,
+ double xScale=1.0);
static void drawTextAligned(
const QString& fileName,
const QString& text,
diff --git a/sources/dataBase/projectdatabase.cpp b/sources/dataBase/projectdatabase.cpp
index ed5d4eebe..da490ecf6 100644
--- a/sources/dataBase/projectdatabase.cpp
+++ b/sources/dataBase/projectdatabase.cpp
@@ -24,6 +24,7 @@
#include "diagramposition.h"
#include
+#include
#if defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS)
#include
@@ -161,7 +162,11 @@ void projectDataBase::addDiagram(Diagram *diagram)
for (auto key : QETApp::diagramInfoKeys())
{
if (key == "date") {
- m_insert_diagram_info_query.bindValue(":date", QDate::fromString(infos.value("date").toString(), Qt::SystemLocaleShortDate));
+ m_insert_diagram_info_query.bindValue(
+ ":date",
+ QLocale::system().toString(
+ infos.value("date").toDate(),
+ QLocale::ShortFormat));
} else {
auto value = infos.value(key);
auto bind = key.prepend(":");
@@ -419,7 +424,11 @@ void projectDataBase::populateDiagramInfoTable()
for (auto key : QETApp::diagramInfoKeys())
{
if (key == "date") {
- m_insert_diagram_info_query.bindValue(":date", QDate::fromString(infos.value("date").toString(), Qt::SystemLocaleShortDate));
+ m_insert_diagram_info_query.bindValue(
+ ":date",
+ QLocale::system().toString(
+ infos.value("date").toDate(),
+ QLocale::ShortFormat));
} else {
auto value = infos.value(key);
auto bind = key.prepend(":");
@@ -521,7 +530,7 @@ sqlite3 *projectDataBase::sqliteHandle(QSqlDatabase *db)
{
//sqlite 3 lib isn't availlable for the moment on macosx
//need some help to add sqlite3 lib on macosx compilation
-#if Q_OS_MACOS
+#ifdef Q_OS_MACOS
return nullptr;
#else
sqlite3 *handle = nullptr;
@@ -553,7 +562,9 @@ void projectDataBase::exportDb(projectDataBase *db,
if (caption_.isEmpty()) {
caption_ = tr("Exporter la base de données interne du projet");
}
-
+#ifdef Q_OS_MACOS
+ return;
+#else
auto dir_ = dir;
if(dir_.isEmpty()) {
dir_ = db->project()->filePath();
@@ -593,4 +604,5 @@ void projectDataBase::exportDb(projectDataBase *db,
file_db.close();
}
QSqlDatabase::removeDatabase(connection_name);
+#endif
}
diff --git a/sources/dataBase/ui/elementquerywidget.h b/sources/dataBase/ui/elementquerywidget.h
index 8cf806058..0196b8d60 100644
--- a/sources/dataBase/ui/elementquerywidget.h
+++ b/sources/dataBase/ui/elementquerywidget.h
@@ -20,6 +20,7 @@
#include
#include
+#include
class QListWidgetItem;
diff --git a/sources/diagramcontext.cpp b/sources/diagramcontext.cpp
index 2e0ddf8de..b7e711099 100644
--- a/sources/diagramcontext.cpp
+++ b/sources/diagramcontext.cpp
@@ -1,24 +1,25 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#include "diagramcontext.h"
-#include
#include "qet.h"
#include
+#include
+#include
/**
@brief DiagramContext::add
@@ -241,8 +242,9 @@ bool DiagramContext::stringLongerThan(const QString &a, const QString &b) {
*/
bool DiagramContext::keyIsAcceptable(const QString &key) const
{
- QRegExp re(DiagramContext::validKeyRegExp());
- return(re.exactMatch(key));
+ QRegularExpression re(DiagramContext::validKeyRegExp());
+ QRegularExpressionMatch match =re.match(key);
+ return match.hasMatch();
}
QDebug operator <<(QDebug debug, const DiagramContext &context)
diff --git a/sources/diagramposition.cpp b/sources/diagramposition.cpp
index df4632a2d..cfdae4a9b 100644
--- a/sources/diagramposition.cpp
+++ b/sources/diagramposition.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -29,7 +29,7 @@
DiagramPosition::DiagramPosition(const QString &letter, unsigned int number) {
// purifie les lettres
letter_ = letter.toUpper();
- letter_.remove(QRegExp("[^A-Z]"));
+ letter_.remove(QRegularExpression("[^A-Z]"));
number_ = number;
}
@@ -64,7 +64,7 @@ QString DiagramPosition::toString()
return("-");
}
QSettings settings;
-
+
if (settings.value("border-columns_0", true).toBool()){
return(QString("%1%2").arg(letter_).arg(number_ - 1));
}else{
diff --git a/sources/diagramposition.h b/sources/diagramposition.h
index b6eb7e79e..8d2add4e8 100644
--- a/sources/diagramposition.h
+++ b/sources/diagramposition.h
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -19,7 +19,6 @@
#define DIAGRAM_POSITION_H
#include
#include
-#include
/**
This class stores the position of an electrical element on its parent diagram.
While exact coordinates can be stored for convenience, the concept of diagram
@@ -31,7 +30,7 @@ class DiagramPosition {
public:
DiagramPosition(const QString & = "", unsigned int = 0);
virtual ~DiagramPosition();
-
+
// methods
public:
QPointF position() const;
@@ -40,7 +39,7 @@ class DiagramPosition {
bool isOutOfBounds() const;
unsigned int number()const {return number_;}
QString letter()const {return letter_;}
-
+
// attributes
private:
QString letter_;
diff --git a/sources/diagramprintdialog.cpp b/sources/diagramprintdialog.cpp
index 36e6b6118..bd4b8cdd4 100644
--- a/sources/diagramprintdialog.cpp
+++ b/sources/diagramprintdialog.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -38,7 +38,7 @@ DiagramPrintDialog::DiagramPrintDialog(QETProject *project, QWidget *parent) :
{
// initialise l'imprimante
printer_ = new QPrinter();
-
+
// orientation paysage par defaut
printer_ -> setOrientation(QPrinter::Landscape);
backup_diagram_background_color = Diagram::background_color;
@@ -95,16 +95,16 @@ QRect DiagramPrintDialog::diagramRect(Diagram *diagram,
const ExportProperties &options) const
{
if (!diagram) return(QRect());
-
+
QRectF diagram_rect = diagram -> border_and_titleblock.borderAndTitleBlockRect();
if (!options.draw_titleblock) {
qreal titleblock_height = diagram -> border_and_titleblock.titleBlockRect().height();
diagram_rect.setHeight(diagram_rect.height() - titleblock_height);
}
-
+
// ajuste la bordure du schema d'un pixel (epaisseur du trait)
diagram_rect = diagram_rect.adjusted(0.0, 0.0, 1.0, 1.0);
-
+
return(diagram_rect.toAlignedRect());
}
@@ -113,16 +113,16 @@ QRect DiagramPrintDialog::diagramRect(Diagram *diagram,
*/
void DiagramPrintDialog::exec()
{
-
+
// prise en compte du nom du document
if (!doc_name_.isEmpty()) printer_ -> setDocName(doc_name_);
printer_ -> setCreator(QString("QElectroTech %1").arg(QET::displayedVersion));
-
+
// affichage d'un premier dialogue demandant a l'utilisateur le type
// d'impression qu'il souhaite effectuer
buildPrintTypeDialog();
if (dialog_ -> exec() == QDialog::Rejected) return;
-
+
// parametrage de l'imprimante en fonction du type d'impression choisi
if (printer_choice_ -> isChecked()) {
// affichage du dialogue d'impression standard pour parametrer l'imprimante
@@ -141,7 +141,7 @@ void DiagramPrintDialog::exec()
}
loadPageSetupForCurrentPrinter();
-
+
//Preview before print
#if defined Q_OS_LINUX
//Due to some bug with xfwm, we display this dialog has a windows on linux os (X11)
@@ -159,9 +159,9 @@ void DiagramPrintDialog::exec()
DiagramsChooser *dc = preview_dialog.diagramsChooser();
dc -> setSelectedAllDiagrams();
if (preview_dialog.exec() == QDialog::Rejected) return;
-
+
savePageSetupForCurrentPrinter();
-
+
// effectue l'impression en elle-meme
print(
dc -> selectedDiagrams(),
@@ -194,7 +194,7 @@ int DiagramPrintDialog::horizontalPagesCount(Diagram *diagram, const ExportPrope
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
QRect diagram_rect = diagramRect(diagram, options);
-
+
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
return(h_pages_count);
}
@@ -211,7 +211,7 @@ int DiagramPrintDialog::verticalPagesCount(Diagram *diagram, const ExportPropert
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
QRect printable_area = fullpage ? printer_ -> paperRect() : printer_ -> pageRect();
QRect diagram_rect = diagramRect(diagram, options);
-
+
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
return(v_pages_count);
}
@@ -227,7 +227,7 @@ void DiagramPrintDialog::buildPrintTypeDialog()
#ifdef Q_OS_MACOS
dialog_ -> setWindowFlags(Qt::Sheet);
#endif
-
+
printtype_label_ = new QLabel(tr("Quel type d'impression désirez-vous effectuer ?"));
printer_icon_ = new QLabel();
pdf_icon_ = new QLabel();
@@ -239,7 +239,7 @@ void DiagramPrintDialog::buildPrintTypeDialog()
filepath_field_ = new QLineEdit();
browse_button_ = new QPushButton("...");
buttons_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-
+
dialog_ -> setWindowTitle(tr("Choix du type d'impression"));
printer_icon_ -> setPixmap(QET::Icons::Printer.pixmap(32, 32));
pdf_icon_ -> setPixmap(QET::Icons::PDF.pixmap(32, 32));
@@ -249,19 +249,19 @@ void DiagramPrintDialog::buildPrintTypeDialog()
printer_choice_ -> setChecked(true);
if (!file_name_.isEmpty()) filepath_field_ -> setText(file_name_ + ".pdf");
-
+
// connexions signaux / slots
connect(printer_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
connect(pdf_choice_, SIGNAL(toggled(bool)), this, SLOT(updatePrintTypeDialog()));
connect(browse_button_, SIGNAL(clicked(bool)), this, SLOT(browseFilePrintTypeDialog()));
connect(buttons_, SIGNAL(accepted()), this, SLOT(acceptPrintTypeDialog()));
connect(buttons_, SIGNAL(rejected()), dialog_, SLOT(reject()));
-
+
// organisation graphique
glayout0_ = new QGridLayout();
hlayout0_ = new QHBoxLayout();
vlayout0_ = new QVBoxLayout();
-
+
hlayout0_ -> addWidget(filepath_field_);
hlayout0_ -> addWidget(browse_button_);
glayout0_ -> addWidget(printer_icon_, 0, 0);
@@ -269,13 +269,13 @@ void DiagramPrintDialog::buildPrintTypeDialog()
glayout0_ -> addWidget(pdf_icon_, 1, 0);
glayout0_ -> addWidget(pdf_choice_, 1, 1);
glayout0_ -> addLayout(hlayout0_, 3, 1);
-
+
vlayout0_ -> addWidget(printtype_label_);
vlayout0_ -> addLayout(glayout0_);
vlayout0_ -> addWidget(buttons_);
-
+
dialog_ -> setLayout(vlayout0_);
-
+
updatePrintTypeDialog();
}
@@ -286,11 +286,11 @@ void DiagramPrintDialog::updatePrintTypeDialog()
{
// imprime-t-on vers un fichier ?
bool file_print = !(printer_choice_ -> isChecked());
-
+
// on n'active le champ fichier que pour les impressions vers un fichier
filepath_field_ -> setEnabled(file_print);
browse_button_ -> setEnabled(file_print);
-
+
// on corrige eventuellement l'extension du fichier deja selectionne
if (file_print)
{
@@ -299,7 +299,9 @@ void DiagramPrintDialog::updatePrintTypeDialog()
{
if (pdf_choice_ -> isChecked() && filepath.endsWith(".ps"))
{
- QRegExp re("\\.ps$", Qt::CaseInsensitive);
+ QRegularExpression re
+ ("\\.ps$",
+ QRegularExpression::CaseInsensitiveOption);
filepath.replace(re, ".pdf");
filepath_field_ -> setText(filepath);
}
@@ -331,7 +333,7 @@ void DiagramPrintDialog::acceptPrintTypeDialog()
}
/**
- Permet a l'utilisateur de choisir un fichier
+ Permet a l'utilisateur de choisir un fichier
*/
void DiagramPrintDialog::browseFilePrintTypeDialog()
{
@@ -343,14 +345,14 @@ void DiagramPrintDialog::browseFilePrintTypeDialog()
extension = ".pdf";
filter = tr("Fichiers PDF (*.pdf)", "file filter");
}
-
+
QString filepath = QFileDialog::getSaveFileName(
parentWidget(),
QString(),
filepath_field_ -> text(),
filter
);
-
+
if (!filepath.isEmpty()) {
if (!filepath.endsWith(extension)) filepath += extension;
filepath = QDir::toNativeSeparators(QDir::cleanPath(filepath));
@@ -390,13 +392,13 @@ void DiagramPrintDialog::print(const QList &diagrams,
#endif
// QPainter utiliser pour effectuer le rendu
QPainter qp(printer_);
-
+
// cas special : il n'y a aucun schema a imprimer
if (!diagrams.count()) {
qp.end();
return;
}
-
+
// imprime les schemas
for (int i = 0 ; i < diagrams.count() ; ++ i) {
printDiagram(diagrams[i], fit_page, options, &qp, printer_);
@@ -422,18 +424,18 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
//qDebug() << printer -> paperSize() << printer -> paperRect() << diagram -> title();
// l'imprimante utilise-t-elle toute la feuille ?
bool full_page = printer -> fullPage();
-
+
// impression physique (!= fichier PDF)
if (printer -> outputFileName().isEmpty()) {
// utiliser cette condition pour agir differemment en cas d'impression physique
}
-
+
saveReloadDiagramParameters(diagram, options, true);
-
+
// deselectionne tous les elements
QList selected_elmts = diagram -> selectedItems();
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
-
+
// enleve le flag focusable de tous les elements concernes pour eviter toute reprise de focus par un champ de texte editable
QList focusable_items;
foreach (QGraphicsItem *qgi, diagram -> items()) {
@@ -442,12 +444,12 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, false);
}
}
-
+
// evite toute autre forme d'interaction
foreach (QGraphicsView *view, diagram -> views()) {
view -> setInteractive(false);
}
-
+
QRect diagram_rect = diagramRect(diagram, options);
if (fit_page) {
// impression adaptee sur une seule page
@@ -458,19 +460,19 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
//qDebug() << "impression sur une ou plusieurs pages";
//qDebug() << " schema :" << diagram_rect;
//qDebug() << " page :" << printed_area;
-
+
int used_width = printed_area.width();
int used_height = printed_area.height();
int h_pages_count = horizontalPagesCount(diagram, options, full_page);
int v_pages_count = verticalPagesCount(diagram, options, full_page);
-
+
QVector< QVector< QRect > > pages_grid;
// le schema est imprime sur une matrice de feuilles
// parcourt les lignes de la matrice
int y_offset = 0;
for (int i = 0 ; i < v_pages_count ; ++ i) {
pages_grid << QVector< QRect >();
-
+
// parcourt les feuilles de la ligne
int x_offset = 0;
for (int j = 0 ; j < h_pages_count ; ++ j) {
@@ -483,10 +485,10 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
);
x_offset += used_width;
}
-
+
y_offset += used_height;
}
-
+
// ne retient que les pages a imprimer
QVector pages_to_print;
for (int i = 0 ; i < v_pages_count ; ++ i) {
@@ -495,7 +497,7 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
}
}
//qDebug() << " " << pages_to_print.count() << " pages a imprimer :";
-
+
// parcourt les pages pour impression
for (int i = 0 ; i < pages_to_print.count() ; ++ i) {
QRect current_rect(pages_to_print.at(i));
@@ -511,20 +513,20 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
}
}
}
-
+
// remet en place les interactions
foreach (QGraphicsView *view, diagram -> views()) {
view -> setInteractive(true);
}
-
+
// restaure les flags focusable
foreach (QGraphicsItem *qgi, focusable_items) {
qgi -> setFlag(QGraphicsItem::ItemIsFocusable, true);
}
-
+
// restaure les elements selectionnes
foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
-
+
saveReloadDiagramParameters(diagram, options, false);
}
@@ -537,7 +539,7 @@ void DiagramPrintDialog::printDiagram(Diagram *diagram,
*/
void DiagramPrintDialog::saveReloadDiagramParameters(Diagram *diagram, const ExportProperties& options, bool save) {
static ExportProperties state_exportProperties;
-
+
if (save) {
// memorise les parametres relatifs au schema tout en appliquant les nouveaux
state_exportProperties = diagram -> applyProperties(options);
@@ -556,11 +558,11 @@ void DiagramPrintDialog::savePageSetupForCurrentPrinter()
{
QSettings settings;
QString printer_section = settingsSectionName(printer_);
-
+
while (!settings.group().isEmpty()) settings.endGroup();
settings.beginGroup("printers");
settings.beginGroup(printer_section);
-
+
settings.setValue("orientation", printer_ -> orientation() == QPrinter::Portrait ? "portrait" : "landscape");
settings.setValue("papersize", int(printer_ -> paperSize()));
if (printer_ -> paperSize() == QPrinter::Custom) {
@@ -592,14 +594,14 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
{
QSettings settings;
QString printer_section = settingsSectionName(printer_);
-
+
while (!settings.group().isEmpty()) settings.endGroup();
settings.beginGroup("printers");
if (!settings.childGroups().contains(printer_section)) {
settings.endGroup();
return;
}
-
+
settings.beginGroup(printer_section);
if (settings.contains("orientation")) {
QString value = settings.value("orientation", "landscape").toString();
@@ -618,7 +620,7 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
printer_ -> setPaperSize(static_cast(value));
}
}
-
+
qreal margins[4];
printer_ -> getPageMargins(&margins[0], &margins[1], &margins[2], &margins[3], QPrinter::Millimeter);
QStringList margins_names(QStringList() << "left" << "top" << "right" << "bottom");
@@ -629,7 +631,7 @@ void DiagramPrintDialog::loadPageSetupForCurrentPrinter()
}
printer_ -> setPageMargins(margins[0], margins[1], margins[2], margins[3], QPrinter::Millimeter);
printer_ -> setFullPage(settings.value("fullpage", "false").toString() == "true");
-
+
settings.endGroup();
settings.endGroup();
}
diff --git a/sources/editor/graphicspart/customelementgraphicpart.cpp b/sources/editor/graphicspart/customelementgraphicpart.cpp
index 73494aa5a..6ffc7f904 100644
--- a/sources/editor/graphicspart/customelementgraphicpart.cpp
+++ b/sources/editor/graphicspart/customelementgraphicpart.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -19,6 +19,8 @@
#include "elementscene.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
+#include
+
/**
@brief CustomElementGraphicPart::CustomElementGraphicPart
Default constructor.
@@ -162,13 +164,13 @@ void CustomElementGraphicPart::setAntialiased(const bool b)
void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
{
QString css_like_styles;
-
+
css_like_styles += "line-style:";
if (_linestyle == DashedStyle) css_like_styles += "dashed";
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
else if (_linestyle == NormalStyle) css_like_styles += "normal";
-
+
css_like_styles += ";line-weight:";
if (_lineweight == NoneWeight) css_like_styles += "none";
else if (_lineweight == ThinWeight) css_like_styles += "thin";
@@ -508,7 +510,7 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
{
resetStyles();
-
+
//Get the list of pair style/value
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
@@ -516,14 +518,14 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
#endif
-
+
//Check each pair of style
- QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
+ QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
foreach (QString style, styles)
{
- if (!rx.exactMatch(style)) continue;
- QString style_name = rx.cap(1);
- QString style_value = rx.cap(2);
+ if (rx!=QRegularExpression(style)) continue;
+ QString style_name = rx.namedCaptureGroups().at(1);
+ QString style_value = rx.namedCaptureGroups().at(2);
if (style_name == "line-style")
{
if (style_value == "dashed") _linestyle = DashedStyle;
@@ -887,13 +889,13 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
//Get the pen and brush
QPen pen = painter.pen();
QBrush brush = painter.brush();
-
+
//Apply pen style
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
-
+
//Apply pen width
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
else if (_lineweight == ThinWeight) pen.setWidth(0);
@@ -1064,7 +1066,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
else if (_filling == HTMLGrayDarkSlateGrayFilling) brush.setColor(QColor(47, 79, 79));
else if (_filling == HTMLGrayBlackFilling) brush.setColor(QColor(0, 0, 0));
}
-
+
//Apply pen color
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
else if (_color == BlackColor) pen.setColor(QColor( 0, 0, 0, pen.color().alpha()));
@@ -1220,12 +1222,12 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
else if (_color == HTMLGrayDarkSlateGrayColor) pen.setColor(QColor(47, 79, 79));
else if (_color == HTMLGrayBlackColor) pen.setColor(QColor(0, 0, 0));
else if (_color == NoneColor) pen.setBrush(Qt::transparent);
-
+
//Apply antialiasing
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
-
+
painter.setPen(pen);
painter.setBrush(brush);
}
diff --git a/sources/editor/graphicspart/partline.cpp b/sources/editor/graphicspart/partline.cpp
index d499e31b7..6e6a799c1 100644
--- a/sources/editor/graphicspart/partline.cpp
+++ b/sources/editor/graphicspart/partline.cpp
@@ -407,54 +407,6 @@ QPainterPath PartLine::shadowShape() const
return (pps.createStroke(shape));
}
-/**
- @brief PartLine::fourShapePoints
- @return a list with the two points that delimite the line
- + the four points surrounding these two points
-*/
-QList PartLine::fourShapePoints() const
-{
- const qreal marge = 2.0;
-
- QPointF a = m_line.p1();
- QPointF b = m_line.p2();
-
- QList result;
-
- //Special case, the line is defined by one point
- if (a == b)
- {
- result << QPointF(a.x() - marge, a.y() - marge);
- result << QPointF(a.x() - marge, a.y() + marge);
- result << QPointF(a.x() + marge, a.y() + marge);
- result << QPointF(a.x() + marge, a.y() - marge);
- }
- else
- {
- //We calcule the vector AB : (xb-xa, yb-ya)
- QPointF v_ab = b - a;
-
- //And the distance AB: root of the coordinates of the vector squared
- qreal ab = sqrt(pow(v_ab.x(), 2) + pow(v_ab.y(), 2));
-
- //Next, we define the vector u(a, b) wich is equal to the vector AB divided
- //by is length and multiplied by the length of marge.
- QPointF u = v_ab / ab * marge;
-
- //We define the vector v(-b, a) wich is perpendicular to AB
- QPointF v(-u.y(), u.x());
- QPointF m = -u + v; // we have vector M = -u + v
- QPointF n = -u - v; // and vector N=-u-v
- QPointF h = a + m; // H = A + M
- QPointF k = a + n; // K = A + N
- QPointF i = b - n; // I = B - N
- QPointF j = b - m; // J = B - M
-
- result << h << i << j << k;
- }
- return(result);
-}
-
/**
@brief PartLine::firstEndCircleRect
@return the rectangle bordering the entirety of the first extremity
@@ -491,35 +443,6 @@ QRectF PartLine::secondEndCircleRect() const
return(end_rect);
}
-/**
- @brief PartLine::debugPaint
- Display several composante of the drawing
- -the bounding rect
- -special points at each extremity
- -the quadrature of the circle at each extremity, even if itself is an other type
- @param painter
-*/
-void PartLine::debugPaint(QPainter *painter)
-{
- painter -> save();
- painter -> setPen(Qt::gray);
- painter -> drawRect(boundingRect());
-
- painter -> setPen(Qt::green);
- painter -> drawRect(firstEndCircleRect());
- painter -> drawRect(secondEndCircleRect());
-
- painter -> setPen(Qt::red);
-
- foreach(QPointF pointy, fourEndPoints(m_line.p1(), m_line.p2(), first_length))
- painter -> drawEllipse(pointy, 0.1, 0.1);
-
- foreach(QPointF pointy, fourEndPoints(m_line.p2(), m_line.p1(), second_length))
- painter -> drawEllipse(pointy, 0.1, 0.1);
-
- painter -> restore();
-}
-
/**
@brief PartLine::boundingRect
@return the bounding rect of this part
diff --git a/sources/editor/graphicspart/partline.h b/sources/editor/graphicspart/partline.h
index 148599ed1..589335ba2 100644
--- a/sources/editor/graphicspart/partline.h
+++ b/sources/editor/graphicspart/partline.h
@@ -110,10 +110,8 @@ class PartLine : public CustomElementGraphicPart
void removeHandler();
QPainterPath path() const;
- QList fourShapePoints() const;
QRectF firstEndCircleRect() const;
QRectF secondEndCircleRect() const;
- void debugPaint(QPainter *);
/*****************/
Qet::EndType first_end;
diff --git a/sources/editor/qetelementeditor.cpp b/sources/editor/qetelementeditor.cpp
index 58ca30be7..846123c09 100644
--- a/sources/editor/qetelementeditor.cpp
+++ b/sources/editor/qetelementeditor.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -83,7 +83,7 @@ QETElementEditor::QETElementEditor(QWidget *parent) :
// la fenetre est maximisee par defaut
setMinimumSize(QSize(500, 350));
setWindowState(Qt::WindowMaximized);
-
+
// lecture des parametres
readSettings();
slot_updateMenus();
@@ -165,7 +165,7 @@ void QETElementEditor::setupActions()
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
"\n"
">> Install on Windows\n"
- "Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
+ "Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
));
#elif defined(Q_OS_MAC)
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
@@ -188,7 +188,7 @@ void QETElementEditor::setupActions()
"Put DXFtoQET binary on your /home/user_name/.qet/ directory\n"
"make it executable : chmod +x ./DXFtoQET\n"
">> Install on Windows\n"
- "Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
+ "Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
"\n"
">> Install on macOSX\n"
"Put DXFtoQET.app binary on /Users/user_name/.qet/ directory \n"
@@ -491,7 +491,7 @@ void QETElementEditor::slot_updateMenus()
// actions dependant du contenu du presse-papiers
paste -> setEnabled(clipboard_elmt);
paste_in_area -> setEnabled(clipboard_elmt);
-
+
// actions dependant de l'etat de la pile d'annulation
save -> setEnabled(!read_only && !m_elmt_scene -> undoStack().isClean());
undo -> setEnabled(!read_only && m_elmt_scene -> undoStack().canUndo());
@@ -534,7 +534,7 @@ void QETElementEditor::setupInterface()
// m_tools_dock_scroll_area = new QScrollArea();
// m_tools_dock_scroll_area -> setFrameStyle(QFrame::NoFrame);
// m_tools_dock_scroll_area -> setAlignment(Qt::AlignHCenter|Qt::AlignTop);
-
+
// Pile de widgets pour accueillir les deux widgets precedents
m_tools_dock_stack = new QStackedWidget();
m_tools_dock_stack -> insertWidget(0, m_default_informations);
@@ -555,7 +555,10 @@ void QETElementEditor::setupInterface()
m_tools_dock = new QDockWidget(tr("Informations", "dock title"), this);
m_tools_dock -> setObjectName("informations");
m_tools_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- m_tools_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
+ m_tools_dock -> setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
//m_tools_dock -> setMinimumWidth(380);
addDockWidget(Qt::RightDockWidgetArea, m_tools_dock);
m_tools_dock -> setWidget(m_tools_dock_stack);
@@ -564,7 +567,10 @@ void QETElementEditor::setupInterface()
m_undo_dock = new QDockWidget(tr("Annulations", "dock title"), this);
m_undo_dock -> setObjectName("undo");
m_undo_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- m_undo_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
+ m_undo_dock -> setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
m_undo_dock -> setMinimumWidth(290);
addDockWidget(Qt::RightDockWidgetArea, m_undo_dock);
QUndoView* undo_view = new QUndoView(&(m_elmt_scene -> undoStack()), this);
@@ -582,7 +588,10 @@ void QETElementEditor::setupInterface()
m_parts_dock = new QDockWidget(tr("Parties", "dock title"), this);
m_parts_dock -> setObjectName("parts_list");
m_parts_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- m_parts_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
+ m_parts_dock -> setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
m_parts_dock -> setMinimumWidth(290);
tabifyDockWidget(m_undo_dock, m_parts_dock);
m_parts_dock -> setWidget(m_parts_list);
@@ -1126,10 +1135,10 @@ void QETElementEditor::slot_openFile()
{
// repertoire a afficher initialement dans le dialogue
QString open_dir = filename_.isEmpty() ? QETApp::customElementsDir() : QDir(filename_).absolutePath();
-
+
// demande un nom de fichier a ouvrir a l'utilisateur
QString user_filename = QETElementEditor::getOpenElementFileName(this, open_dir);
-
+
// ouvre l'element
openElement(user_filename);
}
@@ -1445,7 +1454,7 @@ void QETElementEditor::slot_createPartsList()
m_parts_list -> blockSignals(true);
m_parts_list -> clear();
QList qgis = m_elmt_scene -> zItems();
-
+
// on ne construit plus la liste a partir de 200 primitives
// c'est ingerable : la maj de la liste prend trop de temps et le resultat
// est inexploitable
diff --git a/sources/editor/styleeditor.cpp b/sources/editor/styleeditor.cpp
index 3103eb46e..121cbfba1 100644
--- a/sources/editor/styleeditor.cpp
+++ b/sources/editor/styleeditor.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -200,7 +200,7 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
line_style -> addItem(tr("Pointillé", "element part line style"), CustomElementGraphicPart::DottedStyle);
line_style -> addItem(tr("Traits et points", "element part line style"), CustomElementGraphicPart::DashdottedStyle);
//normal_style -> setChecked(true);
-
+
// epaisseur
size_weight = new QComboBox(this);
size_weight -> addItem(tr("Nulle", "element part weight"), CustomElementGraphicPart::NoneWeight);
@@ -374,16 +374,16 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
// antialiasing
antialiasing = new QCheckBox(tr("Antialiasing"));
-
+
updateForm();
-
+
auto main_layout = new QVBoxLayout();
- main_layout -> setMargin(0);
-
+ main_layout -> setContentsMargins(0,0,0,0);
+
main_layout -> addWidget(new QLabel("" + tr("Apparence :") + " "));
- outline_color->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
- filling_color->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ outline_color->setSizeAdjustPolicy(QComboBox::AdjustToContents);
+ filling_color->setSizeAdjustPolicy(QComboBox::AdjustToContents);
auto grid_layout = new QGridLayout(this);
grid_layout->addWidget(new QLabel(tr("Contour :")), 0,0, Qt::AlignRight);
grid_layout->addWidget(outline_color, 0, 1);
diff --git a/sources/elementspanelwidget.cpp b/sources/elementspanelwidget.cpp
index 0c97f92c7..b1e3a81db 100644
--- a/sources/elementspanelwidget.cpp
+++ b/sources/elementspanelwidget.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -48,7 +48,7 @@
ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
// initalise le panel d'elements
elements_panel = new ElementsPanel(this);
-
+
// initialise les actions
open_directory = new QAction(QET::Icons::FolderOpen, tr("Ouvrir le dossier correspondant"), this);
copy_path = new QAction(QET::Icons::IC_CopyFile, tr("Copier le chemin"), this);
@@ -67,13 +67,13 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
tbt_edit = new QAction(QET::Icons::TitleBlock, tr("Éditer ce modèle"), this);
tbt_remove = new QAction(QET::Icons::TitleBlock, tr("Supprimer ce modèle"), this);
-
+
prj_del_diagram -> setShortcut(QKeySequence(Qt::Key_Delete));
prj_move_diagram_up -> setShortcut(QKeySequence(Qt::Key_F3));
prj_move_diagram_down -> setShortcut(QKeySequence(Qt::Key_F4));
prj_move_diagram_top -> setShortcut(QKeySequence(Qt::Key_F5));
-
-
+
+
// initialise le champ de texte pour filtrer avec une disposition horizontale
filter_textfield = new QLineEdit(this);
filter_textfield -> setClearButtonEnabled(true);
@@ -81,7 +81,7 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
context_menu = new QMenu(this);
-
+
connect(open_directory, SIGNAL(triggered()), this, SLOT(openDirectoryForSelectedItem()));
connect(copy_path, SIGNAL(triggered()), this, SLOT(copyPathForSelectedItem()));
connect(prj_activate, SIGNAL(triggered()), this, SLOT(activateProject()));
@@ -98,9 +98,9 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
connect(tbt_add, SIGNAL(triggered()), this, SLOT(addTitleBlockTemplate()));
connect(tbt_edit, SIGNAL(triggered()), this, SLOT(editTitleBlockTemplate()));
connect(tbt_remove, SIGNAL(triggered()), this, SLOT(removeTitleBlockTemplate()));
-
+
connect(filter_textfield, SIGNAL(textChanged(const QString &)), this, SLOT(filterEdited(const QString &)));
-
+
connect(elements_panel, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(updateButtons()));
connect(elements_panel, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(handleContextMenu(const QPoint &)));
connect(elements_panel, SIGNAL(requestForDiagram(Diagram*)), this, SIGNAL(requestForDiagram(Diagram*)));
@@ -110,10 +110,10 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
QETApp::instance(),
SLOT(openTitleBlockTemplate(const TitleBlockTemplateLocation &))
);
-
+
// disposition verticale
QVBoxLayout *vlayout = new QVBoxLayout(this);
- vlayout -> setMargin(0);
+ vlayout -> setContentsMargins(0,0,0,0);
vlayout -> setSpacing(0);
vlayout -> addWidget(filter_textfield);
vlayout -> addWidget(elements_panel);
@@ -290,7 +290,7 @@ void ElementsPanelWidget::addTitleBlockTemplate()
{
QTreeWidgetItem *current_item = elements_panel -> currentItem();
if (!current_item) return;
-
+
if (current_item -> type() == QET::TitleBlockTemplatesCollection) {
QETApp::instance() -> openTitleBlockTemplate(
elements_panel -> templateLocationForItem(current_item)
@@ -332,18 +332,18 @@ void ElementsPanelWidget::updateButtons()
{
QTreeWidgetItem *current_item = elements_panel -> currentItem();
int current_type = elements_panel -> currentItemType();
-
+
if (current_type == QET::Project) {
bool is_writable = !(elements_panel -> selectedProject() -> isReadOnly());
prj_add_diagram -> setEnabled(is_writable);
} else if (current_type == QET::Diagram) {
Diagram *selected_diagram = elements_panel -> selectedDiagram();
QETProject *selected_diagram_project = selected_diagram -> project();
-
+
bool is_writable = !(selected_diagram_project -> isReadOnly());
int project_diagrams_count = selected_diagram_project -> diagrams().count();
int diagram_position = selected_diagram_project -> diagrams().indexOf(selected_diagram);
-
+
prj_del_diagram -> setEnabled(is_writable);
prj_move_diagram_up -> setEnabled(is_writable && diagram_position > 0);
prj_move_diagram_down -> setEnabled(is_writable && diagram_position < project_diagrams_count - 1);
@@ -373,17 +373,17 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
// recupere l'item concerne par l'evenement ainsi que son chemin
QTreeWidgetItem *item = elements_panel -> itemAt(pos);
if (!item) return;
-
+
updateButtons();
context_menu -> clear();
-
+
QString dir_path = elements_panel -> dirPathForItem(item);
if (!dir_path.isEmpty()) {
context_menu -> addAction(open_directory);
context_menu -> addAction(copy_path);
context_menu -> addSeparator();
}
-
+
switch(item -> type()) {
case QET::Project:
context_menu -> addAction(prj_activate);
@@ -408,7 +408,7 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
context_menu -> addAction(tbt_remove);
break;
}
-
+
// affiche le menu
if (!context_menu -> isEmpty()) {
context_menu -> popup(mapToGlobal(elements_panel -> mapTo(this, pos + QPoint(2, 2))));
diff --git a/sources/elementtextsmover.h b/sources/elementtextsmover.h
index 9428b35fa..e53facd91 100644
--- a/sources/elementtextsmover.h
+++ b/sources/elementtextsmover.h
@@ -20,6 +20,7 @@
#include
#include
+#include
class QGraphicsItem;
class DiagramTextItem;
@@ -37,16 +38,16 @@ class ElementTextsMover
ElementTextsMover();
private:
ElementTextsMover(const ElementTextsMover &);
-
+
public:
bool isReady() const;
int beginMovement(Diagram *diagram, QGraphicsItem *driver_item = nullptr);
void continueMovement(QGraphicsSceneMouseEvent *event);
void endMovement();
-
+
private:
QString undoText() const;
-
+
private:
bool m_movement_running = false;
Diagram *m_diagram = nullptr;
diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp
index 67d908aa3..f79f6bdc5 100644
--- a/sources/exportdialog.cpp
+++ b/sources/exportdialog.cpp
@@ -443,18 +443,10 @@ void ExportDialog::generateDxf(
//Add project elements (lines, rectangles, circles, texts) to dxf file
if (epw -> exportProperties().draw_border) {
- double bx0 = Diagram::margin * Createdxf::xScale;
- double by0 = Diagram::margin * Createdxf::yScale;
- Createdxf::drawRectangle(
- file_path,
- bx0,
- -by0,
- double(width)*Createdxf::xScale,
- double(height)*Createdxf::yScale,
- 0);
+ QRectF rect(Diagram::margin,Diagram::margin,width,height);
+ Createdxf::drawRectangle(file_path,rect,0);
}
- diagram -> border_and_titleblock.drawDxf(file_path,
- 0);
+ diagram -> border_and_titleblock.drawDxf(file_path, 0);
// Build the lists of elements.
QList list_elements;
@@ -503,9 +495,6 @@ void ExportDialog::generateDxf(
qreal elem_pos_x = elmt -> pos().x();
qreal elem_pos_y = elmt -> pos().y();// - (diagram -> margin / 2);
- qreal hotspot_x = (elem_pos_x) * Createdxf::xScale;
- qreal hotspot_y = Createdxf::sheetHeight - (elem_pos_y) * Createdxf::yScale;
-
ElementPictureFactory::primitives primitives = ElementPictureFactory::instance()->getPrimitives(elmt->location());
for(QGraphicsSimpleTextItem *text : primitives.m_texts)
@@ -514,125 +503,82 @@ void ExportDialog::generateDxf(
if (fontSize < 0)
fontSize = text->font().pixelSize();
- fontSize *= Createdxf::yScale;
qreal x = elem_pos_x + text->pos().x();
qreal y = elem_pos_y + text->pos().y();
- x *= Createdxf::xScale;
- y = Createdxf::sheetHeight - (y * Createdxf::yScale);
qreal angle = text -> rotation() + rotation_angle;
qreal angler = angle * M_PI/180;
int xdir = -sin(angler);
int ydir = -cos(angler);
- QPointF transformed_point = rotation_transformed(x, y, hotspot_x, hotspot_y, rotation_angle);
+ QPointF transformed_point = rotation_transformed(x, y, elem_pos_x, elem_pos_y, -rotation_angle);
x = transformed_point.x() - ydir * fontSize * 0.5;
- y = transformed_point.y() + xdir * fontSize * 0.5;
+ y = transformed_point.y() - xdir * fontSize * 0.5;
QStringList lines = text->text().split('\n');
qreal offset = fontSize * 1.6;
for (QString line : lines)
{
if (line.size() > 0 && line != "_" ) {
- Createdxf::drawText(file_path, line, x, y, fontSize, 360 - angle, 0, 0.72);
+ Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360 - angle, 0, 0.72);
}
x += offset * xdir;
- y += offset * ydir;
+ y -= offset * ydir;
}
}
for (QLineF line : primitives.m_lines)
{
- qreal x1 = (elem_pos_x + line.p1().x()) * Createdxf::xScale;
- qreal y1 = Createdxf::sheetHeight - (elem_pos_y + line.p1().y()) * Createdxf::yScale;
- QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
- x1 = transformed_point.x();
- y1 = transformed_point.y();
- qreal x2 = (elem_pos_x + line.p2().x()) * Createdxf::xScale;
- qreal y2 = Createdxf::sheetHeight - (elem_pos_y + line.p2().y()) * Createdxf::yScale;
- transformed_point = rotation_transformed(x2, y2, hotspot_x, hotspot_y, rotation_angle);
- x2 = transformed_point.x();
- y2 = transformed_point.y();
- Createdxf::drawLine(file_path, x1, y1, x2, y2, 0);
+ QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
+ QLineF l = t.map(line);
+ Createdxf::drawLine(file_path, l, 0);
}
for (QRectF rect : primitives.m_rectangles)
{
- qreal x1 = (elem_pos_x + rect.bottomLeft().x()) * Createdxf::xScale;
- qreal y1 = Createdxf::sheetHeight - (elem_pos_y + rect.bottomLeft().y()) * Createdxf::yScale;
- qreal w = rect.width() * Createdxf::xScale;
- qreal h = rect.height() * Createdxf::yScale;
- // opposite corner
- qreal x2 = x1 + w;
- qreal y2 = y1 + h;
- QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
- x1 = transformed_point.x();
- y1 = transformed_point.y();
- transformed_point = rotation_transformed(x2, y2, hotspot_x, hotspot_y, rotation_angle);
- x2 = transformed_point.x();
- y2 = transformed_point.y();
- qreal bottom_left_x = (x1 < x2) ? x1 : x2;
- qreal bottom_left_y = (y1 < y2) ? y1 : y2;
- w = (x1 < x2) ? x2-x1 : x1-x2;
- h = (y1 < y2) ? y2-y1 : y1-y2;
- Createdxf::drawRectangle(file_path, bottom_left_x, bottom_left_y, w, h, 0);
+ QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
+ QRectF r = t.mapRect(rect);
+ Createdxf::drawRectangle(file_path,r,0);
}
for (QRectF circle_rect : primitives.m_circles)
{
- qreal x1 = (elem_pos_x + circle_rect.center().x()) * Createdxf::xScale;
- qreal y1 = Createdxf::sheetHeight - (elem_pos_y + circle_rect.center().y()) * Createdxf::yScale;
- qreal r = circle_rect.width() * Createdxf::xScale / 2;
- QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
- x1 = transformed_point.x();
- y1 = transformed_point.y();
- Createdxf::drawCircle(file_path, r, x1, y1, 0);
+ QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
+ QPointF c = t.map(QPointF(circle_rect.center().x(),circle_rect.center().y()));
+ Createdxf::drawCircle(file_path,c,circle_rect.width()/2,0);
}
for (QVector polygon : primitives.m_polygons)
{
if (polygon.size() == 0)
continue;
- qreal x1 = (elem_pos_x + polygon.at(0).x()) * Createdxf::xScale;
- qreal y1 = Createdxf::sheetHeight - (elem_pos_y + polygon.at(0).y()) * Createdxf::yScale;
- QPointF transformed_point = rotation_transformed(x1, y1, hotspot_x, hotspot_y, rotation_angle);
- x1 = transformed_point.x();
- y1 = transformed_point.y();
- for (int i = 1; i < polygon.size(); ++i ) {
- qreal x2 = (elem_pos_x + polygon.at(i).x()) * Createdxf::xScale;
- qreal y2 = Createdxf::sheetHeight - (elem_pos_y + polygon.at(i).y()) * Createdxf::yScale;
- QPointF transformed_point = rotation_transformed(x2, y2, hotspot_x, hotspot_y, rotation_angle);
- x2 = transformed_point.x();
- y2 = transformed_point.y();
- Createdxf::drawLine(file_path, x1, y1, x2, y2, 0);
- x1 = x2;
- y1 = y2;
- }
+ QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
+ QPolygonF poly = t.map(polygon);
+ Createdxf::drawPolygon(file_path,poly,0);
}
// Draw arcs and ellipses
for (QVector arc : primitives.m_arcs)
{
- if (arc.size() == 0)
- continue;
- qreal x = (elem_pos_x + arc.at(0)) * Createdxf::xScale;
- qreal y = Createdxf::sheetHeight - (elem_pos_y + arc.at(1)) * Createdxf::yScale;
- qreal w = arc.at(2) * Createdxf::xScale;
- qreal h = arc.at(3) * Createdxf::yScale;
- qreal startAngle = arc.at(4);
- qreal spanAngle = arc .at(5);
- Createdxf::drawArcEllipse(file_path, x, y, w, h, startAngle, spanAngle, hotspot_x, hotspot_y, rotation_angle, 0);
+ if (arc.size() == 0)
+ continue;
+ qreal x = (elem_pos_x + arc.at(0));
+ qreal y = (elem_pos_y + arc.at(1));
+ qreal w = arc.at(2);
+ qreal h = arc.at(3);
+ qreal startAngle = arc.at(4);
+ qreal spanAngle = arc .at(5);
+ QRectF r(x,y,w,h);
+ QPointF hotspot(elem_pos_x,elem_pos_y);
+ Createdxf::drawArcEllipse(file_path, r, startAngle, spanAngle, hotspot, rotation_angle, 0);
}
if (epw -> exportProperties().draw_terminals) {
// Draw terminals
QList list_terminals = elmt->terminals();
QColor col("red");
+ QTransform t = QTransform().translate(elem_pos_x,elem_pos_y).rotate(rotation_angle);
foreach(Terminal *tp, list_terminals) {
- qreal x = (elem_pos_x + tp->dock_elmt_.x()) * Createdxf::xScale;
- qreal y = Createdxf::sheetHeight - (elem_pos_y + tp->dock_elmt_.y()) * Createdxf::yScale;
- QPointF transformed_point = rotation_transformed(x, y, hotspot_x, hotspot_y, rotation_angle);
- x = transformed_point.x();
- y = transformed_point.y();
- Createdxf::drawCircle(file_path, 3.0* Createdxf::xScale, x, y, Createdxf::dxfColor(col));
+ QPointF c = t.map(QPointF(tp->dock_elmt_.x(),tp->dock_elmt_.y()));
+ Createdxf::drawCircle(file_path,c,3.0,Createdxf::dxfColor(col));
}
}
}
@@ -652,31 +598,32 @@ void ExportDialog::generateDxf(
Createdxf::drawPolyline(file_path,poly,0);
//Draw conductor text item
ConductorTextItem *textItem = cond -> textItem();
- if (textItem) {
- qreal fontSize = textItem -> font().pointSizeF();
- if (fontSize < 0)
- fontSize = textItem -> font().pixelSize();
- fontSize *= Createdxf::yScale;
+
+ if (textItem) {
+ qreal fontSize = textItem -> font().pointSizeF();
+ if (fontSize < 0)
+ fontSize = textItem -> font().pixelSize();
qreal angle = textItem -> rotation();
qreal angler = angle * M_PI/180;
int xdir = -sin(angler);
int ydir = -cos(angler);
- qreal x = (cond->pos().x() + textItem -> pos().x()) * Createdxf::xScale
+ qreal x = (cond->pos().x() + textItem -> pos().x())
+ xdir * fontSize * 1.8
- ydir * fontSize;
- qreal y = Createdxf::sheetHeight - ((cond->pos().y() + textItem -> pos().y()) * Createdxf::yScale)
- + ydir * fontSize * 1.8
- + xdir * fontSize * 0.9;
+ qreal y = (cond->pos().y() + textItem -> pos().y())
+ - ydir * fontSize * 1.8
+ - xdir * fontSize * 0.9;
QStringList lines = textItem->toPlainText().split('\n');
qreal offset = fontSize * 1.6;
foreach (QString line, lines) {
if (line.size() > 0 && line != "_" )
- Createdxf::drawText(file_path, line, x, y, fontSize, 360-angle, 0, 0.72 );
+ Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, 0, 0.72 );
x += offset * xdir;
- y += offset * ydir;
+ y -= offset * ydir;
}
- }
+ }
+
// Draw the junctions
QList junctions_list = cond->junctions();
if (!junctions_list.isEmpty()) {
@@ -687,30 +634,38 @@ void ExportDialog::generateDxf(
}
//Draw text items
- foreach(DiagramTextItem *dti, list_texts) {
- qreal fontSize = dti -> font().pointSizeF();
- if (fontSize < 0)
- fontSize = dti -> font().pixelSize();
- fontSize *= Createdxf::yScale;
+ foreach(DiagramTextItem *dti, list_texts) {
+ qreal fontSize = dti -> font().pointSizeF();
+ if (fontSize < 0)
+ fontSize = dti -> font().pixelSize();
+
qreal angle = dti -> rotation();
+
+ QGraphicsItem *parent = dti->parentItem();
+ while (parent) {
+ angle += parent->rotation();
+ parent = parent->parentItem();
+ }
+
qreal angler = angle * M_PI/180;
int xdir = -sin(angler);
int ydir = -cos(angler);
- qreal x = (dti->scenePos().x()) * Createdxf::xScale
+ qreal x = (dti->scenePos().x())
+ xdir * fontSize * 1.8
- ydir * fontSize;
- qreal y = Createdxf::sheetHeight - (dti->scenePos().y() * Createdxf::yScale)
- + ydir * fontSize * 1.8
- + xdir * fontSize * 0.9;
- QStringList lines = dti -> toPlainText().split('\n');
+ qreal y = dti->scenePos().y()
+ - ydir * fontSize * 1.8
+ - xdir * fontSize * 0.9;
+ QStringList lines = dti -> toPlainText().split('\n');
qreal offset = fontSize * 1.6;
foreach (QString line, lines) {
if (line.size() > 0 && line != "_" )
- Createdxf::drawText(file_path, line, x, y, fontSize, 360-angle, 0, 0.72 );
+ Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, Createdxf::dxfColor(dti->color()), 0.72 );
x += offset * xdir;
- y += offset * ydir;
+ y -= offset * ydir;
}
- }
+ }
+
Createdxf::dxfEnd(file_path);
saveReloadDiagramParameters(diagram, false);
diff --git a/sources/factory/elementpicturefactory.cpp b/sources/factory/elementpicturefactory.cpp
index d21b237ae..4dd11ff0f 100644
--- a/sources/factory/elementpicturefactory.cpp
+++ b/sources/factory/elementpicturefactory.cpp
@@ -28,6 +28,7 @@
#include
#include
#include
+#include
ElementPictureFactory* ElementPictureFactory::m_factory = nullptr;
@@ -44,14 +45,14 @@ void ElementPictureFactory::getPictures(const ElementsLocation &location, QPictu
if(!location.exist()) {
return;
}
-
+
QUuid uuid = location.uuid();
if(Q_UNLIKELY(uuid.isNull()))
{
build(location, &picture, &low_picture);
return;
}
-
+
if(m_pictures_H.keys().contains(uuid))
{
picture = m_pictures_H.value(uuid);
@@ -76,11 +77,11 @@ void ElementPictureFactory::getPictures(const ElementsLocation &location, QPictu
QPixmap ElementPictureFactory::pixmap(const ElementsLocation &location)
{
QUuid uuid = location.uuid();
-
+
if (m_pixmap_H.contains(uuid)) {
return m_pixmap_H.value(uuid);
}
-
+
if(build(location))
{
auto doc = location.pugiXml();
@@ -95,19 +96,19 @@ QPixmap ElementPictureFactory::pixmap(const ElementsLocation &location)
QPixmap pix(w, h);
pix.fill(QColor(255, 255, 255, 0));
-
+
QPainter painter(&pix);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
painter.translate(hsx, hsy);
painter.drawPicture(0, 0, m_pictures_H.value(uuid));
-
+
if (!uuid.isNull()) {
m_pixmap_H.insert(uuid, pix);
}
return pix;
}
-
+
return QPixmap();
}
@@ -122,7 +123,7 @@ ElementPictureFactory::primitives ElementPictureFactory::getPrimitives(
{
if(!m_primitives_H.contains(location.uuid()))
build(location);
-
+
return m_primitives_H.value(location.uuid());
}
@@ -143,14 +144,14 @@ ElementPictureFactory::~ElementPictureFactory()
this function draw on it and don't store it.
if null, this function create a QPicture for normal and low zoom,
draw on it and store it in m_pictures_H and m_low_pictures_H
- @return
+ @return
*/
bool ElementPictureFactory::build(const ElementsLocation &location,
QPicture *picture,
QPicture *low_picture)
{
QDomElement dom = location.xml();
-
+
//Check if the curent version can read the xml description
if (dom.hasAttribute("version"))
{
@@ -165,7 +166,7 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
) << std::endl;
}
}
-
+
//This attributes must be present and valid
int w, h, hot_x, hot_y;
if (!QET::attributeIsAnInteger(dom, QString("width"), &w) ||\
@@ -175,7 +176,7 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
{
return(false);
}
-
+
QPainter painter;
QPicture pic;
primitives primitives_;
@@ -188,8 +189,8 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::TextAntialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform,true);
-
-
+
+
QPainter low_painter;
QPicture low_pic;
if (low_picture) {
@@ -201,12 +202,12 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
low_painter.setRenderHint(QPainter::Antialiasing, true);
low_painter.setRenderHint(QPainter::TextAntialiasing, true);
low_painter.setRenderHint(QPainter::SmoothPixmapTransform,true);
-
+
QPen tmp;
tmp.setWidthF(1.0); //Vaudoo line to take into account the setCosmetic - don't remove
tmp.setCosmetic(true);
low_painter.setPen(tmp);
-
+
//scroll of the Children of the Definition: Parts of the Drawing
for (QDomNode node = dom.firstChild() ; !node.isNull() ; node = node.nextSibling())
{
@@ -214,9 +215,9 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
if (elmts.isNull()) {
continue;
}
-
+
if (elmts.tagName() == "description")
- {
+ {
//Manage the graphic description = part of drawing
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling())
{
@@ -230,7 +231,7 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
}
}
}
-
+
//End of the drawing
painter.end();
low_painter.end();
@@ -458,7 +459,7 @@ void ElementPictureFactory::parsePolygon(const QDomElement &dom, QPainter &paint
if (i < 3) {
return;
}
-
+
QVector points; // empty vector created instead of default initialized vector with i-1 elements.
for (int j = 1 ; j < i ; ++ j) {
points.insert(
@@ -568,11 +569,11 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa
#pragma message("@TODO remove code for QT 5.14 or later")
const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts);
#endif
- QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
+ QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
for (QString style : styles) {
- if (rx.exactMatch(style)) {
- QString style_name = rx.cap(1);
- QString style_value = rx.cap(2);
+ if (rx==QRegularExpression(style)) {
+ QString style_name = rx.namedCaptureGroups().at(1);
+ QString style_value = rx.namedCaptureGroups().at(2);
if (style_name == "line-style") {
if (style_value == "dashed") pen.setStyle(Qt::DashLine);
else if (style_value == "dotted") pen.setStyle(Qt::DotLine);
diff --git a/sources/factory/propertieseditorfactory.cpp b/sources/factory/propertieseditorfactory.cpp
index d14a7ea4a..d01407f79 100644
--- a/sources/factory/propertieseditorfactory.cpp
+++ b/sources/factory/propertieseditorfactory.cpp
@@ -77,26 +77,21 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
PropertiesEditorWidget *editor,
QWidget *parent)
{
- int count_ = items.size();
+ const int count_ = items.size();
+ if (count_ == 0) {
+ return nullptr;
+ }
+ QGraphicsItem *item = items.first();
+ const int type_ = item->type();
//The editor widget can only edit one item
//or several items of the same type
- if (count_ != 1)
- {
- if (count_ == 0) {
+ for (auto qgi : items) {
+ if (qgi->type() != type_) {
return nullptr;
}
-
- int type_ = items.first()->type();
- for (QGraphicsItem *qgi : items) {
- if (qgi->type() != type_) {
- return nullptr;
- }
- }
}
- QGraphicsItem *item = items.first();
- const int type_ = item->type();
QString class_name;
if (editor) {
class_name = editor->metaObject()->className();
diff --git a/sources/main.cpp b/sources/main.cpp
index 43c90af2b..bbaea47b9 100644
--- a/sources/main.cpp
+++ b/sources/main.cpp
@@ -203,7 +203,6 @@ int main(int argc, char **argv)
my_ma->send_info_to_debug();
delete my_ma;
}
-
return app.exec();
}
diff --git a/sources/properties/xrefproperties.cpp b/sources/properties/xrefproperties.cpp
index c89077ec8..dd864f5b0 100644
--- a/sources/properties/xrefproperties.cpp
+++ b/sources/properties/xrefproperties.cpp
@@ -15,9 +15,11 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
+#include
+#include
+
#include "xrefproperties.h"
#include "qetapp.h"
-#include
/**
@brief XRefProperties::XRefProperties
@@ -56,7 +58,7 @@ void XRefProperties::toSettings(QSettings &settings,
QString slave_label = m_slave_label;
settings.setValue(prefix + "slave_label", slave_label);
-
+
QMetaEnum var = QMetaEnum::fromType();
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);
QString xrefpos;
-
+
QMetaEnum var = QMetaEnum::fromType();
xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos));
diff --git a/sources/properties/xrefproperties.h b/sources/properties/xrefproperties.h
index 39cf977af..446060f52 100644
--- a/sources/properties/xrefproperties.h
+++ b/sources/properties/xrefproperties.h
@@ -18,8 +18,10 @@
#ifndef XREFPROPERTIES_H
#define XREFPROPERTIES_H
-#include "propertiesinterface.h"
#include
+#include
+
+#include "propertiesinterface.h"
/**
@brief The XRefProperties class
diff --git a/sources/qet.cpp b/sources/qet.cpp
index dac87f5f3..6f485e193 100644
--- a/sources/qet.cpp
+++ b/sources/qet.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
/**
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
@@ -169,10 +170,10 @@ bool QET::orthogonalProjection(const QPointF &point,
// recupere le vecteur normal de `line'
QLineF line_normal_vector(line.normalVector());
QPointF normal_vector(line_normal_vector.dx(), line_normal_vector.dy());
-
+
// cree une droite perpendiculaire a `line' passant par `point'
QLineF perpendicular_line(point, point + normal_vector);
-
+
// determine le point d'intersection des deux droites = le projete orthogonal
QPointF intersection_point;
@@ -184,15 +185,15 @@ bool QET::orthogonalProjection(const QPointF &point,
intersects
#endif
(perpendicular_line, &intersection_point);
-
+
// ne devrait pas arriver (mais bon...)
if (it == QLineF::NoIntersection) return(false);
-
+
// fournit le point d'intersection a l'appelant si necessaire
if (intersection) {
*intersection = intersection_point;
}
-
+
// determine si le point d'intersection appartient au segment de droite
if (QET::lineContainsPoint(line, intersection_point)) {
return(true);
@@ -272,7 +273,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
elements_count
);
}
-
+
if (conductors_count) {
if (!text.isEmpty()) text += ", ";
text += QObject::tr(
@@ -281,7 +282,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
conductors_count
);
}
-
+
if (texts_count) {
if (!text.isEmpty()) text += ", ";
text += QObject::tr(
@@ -308,7 +309,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
shapes_count
);
}
-
+
if (element_text_count) {
if (!text.isEmpty()) text += ", ";
text += QObject::tr(
@@ -324,7 +325,7 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
"part of a sentence listing the content of diagram",
tables_count);
}
-
+
return(text);
}
@@ -354,7 +355,7 @@ QList QET::findInDomElement(const QDomElement &e,
const QString &parent,
const QString &children) {
QList return_list;
-
+
// parcours des elements parents
for (QDomNode enfant = e.firstChild() ; !enfant.isNull() ; enfant = enfant.nextSibling()) {
// on s'interesse a l'element XML "parent"
@@ -417,15 +418,15 @@ QList QET::forbiddenCharacters()
*/
QString QET::stringToFileName(const QString &name) {
QString file_name(name.toLower());
-
+
// remplace les caracteres interdits par des tirets
foreach(QChar c, QET::forbiddenCharacters()) {
file_name.replace(c, '-');
}
-
+
// remplace les espaces par des underscores
file_name.replace(' ', '_');
-
+
return(file_name);
}
@@ -455,12 +456,12 @@ QString QET::unescapeSpaces(const QString &string) {
*/
QString QET::joinWithSpaces(const QStringList &string_list) {
QString returned_string;
-
+
for (int i = 0 ; i < string_list.count() ; ++ i) {
returned_string += QET::escapeSpaces(string_list.at(i));
if (i != string_list.count() - 1) returned_string += " ";
}
-
+
return(returned_string);
}
@@ -475,7 +476,7 @@ QStringList QET::splitWithSpaces(const QString &string) {
// = avec un nombre nul ou pair de backslashes devant
#pragma message("@TODO remove code for QT 5.14 or later")
- QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "),
+ QStringList escaped_strings = string.split(QRegularExpression("[^\\]?(?:\\\\)* "),
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QString
#else
@@ -570,13 +571,13 @@ bool QET::compareCanonicalFilePaths(const QString &first, const QString &second)
QString second_canonical_path = QFileInfo(second).canonicalFilePath();
if (second_canonical_path.isEmpty()) return(false);
-
+
#ifdef Q_OS_WIN
// sous Windows, on ramene les chemins en minuscules
first_canonical_path = first_canonical_path.toLower();
second_canonical_path = second_canonical_path.toLower();
#endif
-
+
return(first_canonical_path == second_canonical_path);
}
@@ -592,7 +593,7 @@ bool QET::compareCanonicalFilePaths(const QString &first, const QString &second)
bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *error_message)
{
QSaveFile file(filepath);
-
+
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
bool file_opening = file.open(QIODevice::WriteOnly);
if (!file_opening)
@@ -605,7 +606,7 @@ bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *
}
return(false);
}
-
+
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(false);
@@ -617,10 +618,10 @@ bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *
"Une erreur est survenue lors de l'écriture du fichier %1, erreur %2 rencontrée.",
"error message when attempting to write an XML file")).arg(filepath).arg(file.error());
}
-
+
return false;
}
-
+
return(true);
}
@@ -687,7 +688,7 @@ QActionGroup *QET::depthActionGroup(QObject *parent)
{
QActionGroup *action_group = new QActionGroup(parent);
- QAction *edit_forward = new QAction(QET::Icons::BringForward, QObject::tr("Amener au premier plan"), action_group);
+ QAction *edit_forward = new QAction(QET::Icons::BringForward, QObject::tr("Amener au premier plan"), action_group);
QAction *edit_raise = new QAction(QET::Icons::Raise, QObject::tr("Rapprocher"), action_group);
QAction *edit_lower = new QAction(QET::Icons::Lower, QObject::tr("Éloigner"), action_group);
QAction *edit_backward = new QAction(QET::Icons::SendBackward, QObject::tr("Envoyer au fond"), action_group);
@@ -696,17 +697,17 @@ QActionGroup *QET::depthActionGroup(QObject *parent)
edit_raise ->setStatusTip(QObject::tr("Rapproche la ou les sélections"));
edit_lower ->setStatusTip(QObject::tr("Éloigne la ou les sélections"));
edit_backward->setStatusTip(QObject::tr("Envoie en arrière plan la ou les sélections"));
-
+
edit_raise ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Up")));
edit_lower ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Down")));
edit_backward->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+End")));
edit_forward ->setShortcut(QKeySequence(QObject::tr("Ctrl+Shift+Home")));
-
+
edit_forward ->setData(QET::BringForward);
edit_raise ->setData(QET::Raise);
edit_lower ->setData(QET::Lower);
edit_backward->setData(QET::SendBackward);
-
+
return action_group;
}
diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp
index fff72edc4..c2a7aef36 100644
--- a/sources/qetapp.cpp
+++ b/sources/qetapp.cpp
@@ -33,14 +33,14 @@
#include "projectview.h"
#include "elementpicturefactory.h"
#include "aboutqetdialog.h"
+#include "factory/elementfactory.h"
#include
#include
#define QUOTE(x) STRINGIFY(x)
#define STRINGIFY(x) #x
#include
-#include "factory/elementfactory.h"
-
+#include
#include
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
@@ -97,7 +97,7 @@ QETApp::QETApp() :
"splash screen caption"));
if (!collections_cache_) {
QString cache_path = QETApp::configDir() + "/elements_cache.sqlite";
-
+
collections_cache_ = new ElementsCollectionCache(cache_path, this);
collections_cache_->setLocale(langFromSetting());
}
@@ -113,12 +113,12 @@ QETApp::QETApp() :
"splash screen caption"));
openFiles(qet_arguments_);
}
-
+
buildSystemTrayMenu();
if (m_splash_screen) {
m_splash_screen -> hide();
}
-
+
checkBackupFiles();
}
@@ -129,17 +129,17 @@ QETApp::~QETApp()
{
m_elements_recent_files->save();
m_projects_recent_files->save();
-
+
delete m_splash_screen;
delete m_elements_recent_files;
delete m_projects_recent_files;
delete m_qsti;
-
+
if (m_custom_tbt_collection)
delete m_custom_tbt_collection;
if (m_common_tbt_collection)
delete m_common_tbt_collection;
-
+
ElementFactory::dropInstance();
ElementPictureFactory::dropInstance();
}
@@ -409,12 +409,12 @@ QString QETApp::elementTranslatedInfoKey(const QString &info)
else if (info == "label") return tr("Label");
else if (info == "plant") return tr("Installation");
else if (info == "location") return tr("Localisation");
-
+
else if (info == "comment") return tr("Commentaire");
else if (info == "function") return tr("Fonction");
else if (info == "auxiliary1") return tr("Bloc auxiliaire 1");
else if (info == "auxiliary2") return tr("Bloc auxiliaire 2");
-
+
else if (info == "description") return tr("Description textuelle");
else if (info == "designation") return tr("Numéro d'article");
else if (info == "manufacturer") return tr("Fabricant");
@@ -455,7 +455,7 @@ QStringList QETApp::conductorInfoKeys()
keys.append("tension/protocol");
keys.append("conductor_color");
keys.append("conductor_section");
-
+
return keys;
}
@@ -492,7 +492,7 @@ QStringList QETApp::diagramInfoKeys()
list.append("indexrev");
list.append("date");
list.append("display_folio");
-
+
return list;
}
@@ -625,7 +625,7 @@ QString QETApp::commonElementsDir()
else if (m_user_common_elements_dir != "default") {
return m_user_common_elements_dir;
}
-
+
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
if (common_elements_dir != QString()) return(common_elements_dir);
#endif
@@ -687,7 +687,7 @@ QString QETApp::customElementsDir()
else if (m_user_custom_elements_dir != "default") {
return m_user_custom_elements_dir;
}
-
+
return(configDir() + "elements/");
}
@@ -786,7 +786,7 @@ QString QETApp::customTitleBlockTemplatesDir()
else if (m_user_custom_tbt_dir != "default") {
return m_user_custom_tbt_dir;
}
-
+
return(configDir() + "titleblocks/");
}
@@ -911,7 +911,7 @@ QStringList QETApp::handledFileExtensions()
if (!ext.count()) {
ext << "qet";
ext << "elmt";
- ext << QString(TITLEBLOCKS_FILE_EXTENSION).remove(QRegExp("^\\."));
+ ext << QString(TITLEBLOCKS_FILE_EXTENSION).remove(QRegularExpression("^\\."));
}
return(ext);
}
@@ -1159,7 +1159,7 @@ QFont QETApp::diagramTextsItemFont(qreal size)
).toDouble();
QString diagram_texts_item_style = settings.value("diagramitemstyle",
"normal").toString();
-
+
if (size != -1.0) {
diagram_texts_item_size = size;
}
@@ -1359,9 +1359,9 @@ QList QETApp::elementEditors(QETProject *project) {
void QETApp::receiveMessage(int instanceId, QByteArray message)
{
Q_UNUSED(instanceId);
-
+
QString str(message);
-
+
if (str.startsWith("launched-with-args: "))
{
QString my_message(str.mid(20));
@@ -2102,10 +2102,10 @@ template void QETApp::addWindowsListToMenu(
or -1 if none could be found.
*/
int QETApp::projectIdFromString(const QString &url) {
- QRegExp embedded("^project([0-9]+)\\+embed.*$", Qt::CaseInsensitive);
- if (embedded.exactMatch(url)) {
+ QRegularExpression embedded("^project([0-9]+)\\+embed.*$", QRegularExpression::CaseInsensitiveOption);
+ if (embedded==QRegularExpression(url)) {
bool conv_ok = false;
- int project_id = embedded.capturedTexts().at(1).toInt(&conv_ok);
+ int project_id = embedded.namedCaptureGroups().at(1).toInt(&conv_ok);
if (conv_ok) {
return(project_id);
}
@@ -2191,7 +2191,7 @@ void QETApp::buildSystemTrayMenu()
void QETApp::checkBackupFiles()
{
QList stale_files = KAutoSaveFile::allStaleFiles();
-
+
//Remove from the list @stale_files, the stales file of opened project
const QList sf = stale_files;
for (KAutoSaveFile *kasf : sf)
@@ -2227,10 +2227,10 @@ void QETApp::checkBackupFiles()
for(const KAutoSaveFile *kasf : stale_files)
{
#ifdef Q_OS_WIN
- //Remove the first character '/' before the name of the drive
- text.append(" " + kasf->managedFile().path().remove(0,1));
+ //Remove the first character '/' before the name of the drive
+ text.append(" " + kasf->managedFile().path().remove(0,1));
#else
- text.append(" " + kasf->managedFile().path());
+ text.append(" " + kasf->managedFile().path());
#endif
}
@@ -2319,12 +2319,12 @@ void QETApp::fetchWindowStats(
bool QETApp::eventFiltrer(QObject *object, QEvent *e) {
// gere l'ouverture de fichiers (sous MacOs)
if (e -> type() == QEvent::FileOpen) {
- // nom du fichier a ouvrir
- QString filename = static_cast(e) -> file();
- openFiles(QStringList() << filename);
- return(true);
+ // nom du fichier a ouvrir
+ QString filename = static_cast(e) -> file();
+ openFiles(QStringList() << filename);
+ return(true);
} else {
- return QObject::eventFilter(object, e);
+ return QObject::eventFilter(object, e);
}
}
#endif
diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp
index 7e0c0ccf6..f844e0fb2 100644
--- a/sources/qetdiagrameditor.cpp
+++ b/sources/qetdiagrameditor.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -60,7 +60,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
{
activeSubWindowIndex = 0;
-
+
QSplitter *splitter_ = new QSplitter(this);
splitter_->setChildrenCollapsible(false);
splitter_->setOrientation(Qt::Vertical);
@@ -77,19 +77,19 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
anim->setObjectName("search and replace animator");
m_search_and_replace_widget.setHidden(true);
anim->setLastShowSize(m_search_and_replace_widget.minimumSizeHint().height());
-
+
//Set object name to be retrieved by the stylesheets
m_workspace.setBackground(QBrush(Qt::NoBrush));
m_workspace.setObjectName("mdiarea");
m_workspace.setTabsClosable(true);
-
+
//Set the signal mapper
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
-
- setWindowTitle(tr("QElectroTech", "window title"));
+
+ setWindowTitle(tr("QElectroTech", "window title"));
setWindowIcon(QET::Icons::QETLogo);
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
-
+
setUpElementsPanel();
setUpElementsCollectionWidget();
setUpUndoStack();
@@ -101,11 +101,11 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
setUpMenu();
tabifyDockWidget(qdw_undo, qdw_pa);
-
+
//By default the windows is maximised
setMinimumSize(QSize(500, 350));
setWindowState(Qt::WindowMaximized);
-
+
connect (&m_workspace,
SIGNAL(subWindowActivated(QMdiSubWindow *)),
this,
@@ -117,7 +117,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
readSettings();
show();
-
+
//If valid file path is given as arguments
uint opened_projects = 0;
if (files.count())
@@ -149,7 +149,10 @@ void QETDiagramEditor::setUpElementsPanel()
qdw_pa -> setObjectName ("projects panel");
qdw_pa -> setAllowedAreas (Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- qdw_pa -> setFeatures (QDockWidget::AllDockWidgetFeatures);
+ qdw_pa -> setFeatures (
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
qdw_pa -> setMinimumWidth (160);
qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
@@ -179,7 +182,10 @@ void QETDiagramEditor::setUpElementsCollectionWidget()
m_qdw_elmt_collection = new QDockWidget(tr("Collections"), this);
m_qdw_elmt_collection->setObjectName("elements_collection_widget");
m_qdw_elmt_collection->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- m_qdw_elmt_collection->setFeatures(QDockWidget::AllDockWidgetFeatures);
+ m_qdw_elmt_collection->setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
m_element_collection_widget = new ElementsCollectionWidget(m_qdw_elmt_collection);
m_qdw_elmt_collection->setWidget(m_element_collection_widget);
@@ -205,7 +211,10 @@ void QETDiagramEditor::setUpUndoStack()
qdw_undo -> setObjectName("diagram_undo");
qdw_undo -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- qdw_undo -> setFeatures(QDockWidget::AllDockWidgetFeatures);
+ qdw_undo -> setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
qdw_undo -> setMinimumWidth(160);
qdw_undo -> setWidget(undo_view);
@@ -231,7 +240,10 @@ void QETDiagramEditor::setUpAutonumberingWidget()
{
m_autonumbering_dock = new AutoNumberingDockWidget(this);
m_autonumbering_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- m_autonumbering_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
+ m_autonumbering_dock -> setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
addDockWidget(Qt::RightDockWidgetArea, m_autonumbering_dock);
}
@@ -251,7 +263,7 @@ void QETDiagramEditor::setUpActions()
current_project -> exportProject();
}
});
-
+
//Print
m_print = new QAction(QET::Icons::DocumentPrint, tr("Imprimer"), this);
m_print->setShortcut(QKeySequence(QKeySequence::Print));
@@ -262,7 +274,7 @@ void QETDiagramEditor::setUpActions()
current_project -> printProject();
}
});
-
+
//Quit editor
m_quit_editor = new QAction(QET::Icons::ApplicationExit, tr("&Quitter"), this);
m_quit_editor->setShortcut(QKeySequence(tr("Ctrl+Q")));
@@ -314,7 +326,7 @@ void QETDiagramEditor::setUpActions()
if (DiagramView *dv = currentDiagramView())
dv->resetConductors();
});
-
+
//AutoConductor
m_auto_conductor = new QAction (QET::Icons::Autoconnect, tr("Création automatique de conducteur(s)","Tool tip of auto conductor"), this);
m_auto_conductor->setStatusTip (tr("Utiliser la création automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor"));
@@ -358,13 +370,13 @@ void QETDiagramEditor::setUpActions()
project_view->editCurrentDiagramProperties();
}
});
-
+
//Edit current project properties
m_project_edit_properties = new QAction(QET::Icons::ProjectProperties, tr("Propriétés du projet"), this);
connect(m_project_edit_properties, &QAction::triggered, [this]() {
editProjectProperties(currentProjectView());
});
-
+
//Add new folio to current project
m_project_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this);
m_project_add_diagram->setShortcut(QKeySequence(tr("Ctrl+T")));
@@ -373,11 +385,11 @@ void QETDiagramEditor::setUpActions()
current_project->project()->addNewDiagram();
}
});
-
+
//Remove current folio from current project
m_remove_diagram_from_project = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le folio"), this);
connect(m_remove_diagram_from_project, &QAction::triggered, this, &QETDiagramEditor::removeDiagramFromProject);
-
+
//Clean the current project
m_clean_project = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this);
connect(m_clean_project, &QAction::triggered, [this]() {
@@ -394,7 +406,7 @@ void QETDiagramEditor::setUpActions()
BOMExportDialog bom(currentProjectView()->project(), this);
bom.exec();
});
-
+
//Add a nomenclature item
m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter une nomenclature"), this);
connect(m_add_nomenclature, &QAction::triggered, [this]() {
@@ -430,27 +442,27 @@ void QETDiagramEditor::setUpActions()
connect(m_export_project_db, &QAction::triggered, [this]() {
projectDataBase::exportDb(this->currentProject()->dataBase(), this);
});
-
+
//MDI view style
m_tabbed_view_mode = new QAction(tr("en utilisant des onglets"), this);
m_tabbed_view_mode->setStatusTip(tr("Présente les différents projets ouverts des onglets", "status bar tip"));
m_tabbed_view_mode->setCheckable(true);
connect(m_tabbed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setTabbedMode);
-
+
m_windowed_view_mode = new QAction(tr("en utilisant des fenêtres"), this);
m_windowed_view_mode->setStatusTip(tr("Présente les différents projets ouverts dans des sous-fenêtres", "status bar tip"));
m_windowed_view_mode->setCheckable(true);
connect(m_windowed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setWindowedMode);
-
+
m_group_view_mode = new QActionGroup(this);
m_group_view_mode -> addAction(m_windowed_view_mode);
m_group_view_mode -> addAction(m_tabbed_view_mode);
m_group_view_mode -> setExclusive(true);
-
+
m_tile_window = new QAction(tr("&Mosaïque"), this);
m_tile_window->setStatusTip(tr("Dispose les fenêtres en mosaïque", "status bar tip"));
connect(m_tile_window, &QAction::triggered, &m_workspace, &QMdiArea::tileSubWindows);
-
+
m_cascade_window = new QAction(tr("&Cascade"), this);
m_cascade_window->setStatusTip(tr("Dispose les fenêtres en cascade", "status bar tip"));
connect(m_cascade_window, &QAction::triggered, &m_workspace, &QMdiArea::cascadeSubWindows);
@@ -467,7 +479,7 @@ void QETDiagramEditor::setUpActions()
}
}
});
-
+
m_mode_visualise = new QAction(QET::Icons::ViewMove, tr("Mode Visualisation"), this);
m_mode_visualise->setStatusTip(tr("Permet de visualiser le folio sans pouvoir le modifier", "status bar tip"));
m_mode_visualise->setCheckable(true);
@@ -489,7 +501,7 @@ void QETDiagramEditor::setUpActions()
m_next_window->setShortcut(QKeySequence::NextChild);
m_next_window->setStatusTip(tr("Active le projet suivant", "status bar tip"));
connect(m_next_window, &QAction::triggered, &m_workspace, &QMdiArea::activateNextSubWindow);
-
+
m_previous_window = new QAction(tr("Projet précédent"), this);
m_previous_window->setShortcut(QKeySequence::PreviousChild);
m_previous_window->setStatusTip(tr("Active le projet précédent", "status bar tip"));
@@ -645,11 +657,11 @@ void QETDiagramEditor::setUpActions()
//Depth action
m_depth_action_group = QET::depthActionGroup(this);
m_depth_action_group->setDisabled(true);
-
+
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
this->currentDiagramView()->diagram()->changeZValue(action->data().value());
});
-
+
m_find = new QAction(tr("Chercher/remplacer"), this);
m_find->setShortcut(QKeySequence::Find);
connect(m_find, &QAction::triggered, [this]()
@@ -705,7 +717,7 @@ void QETDiagramEditor::setUpToolBar()
m_add_item_tool_bar = new QToolBar(tr("Ajouter"), this);
m_add_item_tool_bar->setObjectName("adding");
m_add_item_tool_bar->addActions(m_add_item_actions_group.actions());
-
+
m_depth_tool_bar = new QToolBar(tr("Profondeur", "toolbar title"));
m_depth_tool_bar->setObjectName("diagram_depth_toolbar");
m_depth_tool_bar->addActions(m_depth_action_group->actions());
@@ -792,7 +804,7 @@ void QETDiagramEditor::setUpMenu()
diagram_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils Schéma"));
qdw_pa -> toggleViewAction() -> setStatusTip(tr("Affiche ou non le panel d'appareils"));
qdw_undo -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la liste des modifications"));
-
+
// menu Affichage
QMenu *projects_view_mode = menu_affichage -> addMenu(QET::Icons::ConfigureToolbars, tr("Afficher les projets"));
@@ -848,7 +860,7 @@ void QETDiagramEditor::closeEvent(QCloseEvent *qce)
Reimplemented to :
-Load elements collection when WindowActivate.
@param e
- @return
+ @return
*/
bool QETDiagramEditor::event(QEvent *e)
{
@@ -916,10 +928,10 @@ void QETDiagramEditor::saveAs()
bool QETDiagramEditor::newProject()
{
auto new_project = new QETProject(this);
-
+
// add new diagram
new_project -> addNewDiagram();
-
+
return addProject(new_project);
}
@@ -952,10 +964,10 @@ bool QETDiagramEditor::openProject()
tr("Projets QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)")
);
if (filepath.isEmpty()) return(false);
-
+
// retient le dossier contenant le dernier projet ouvert
open_dialog_dir = QDir(filepath);
-
+
// ouvre le fichier
return(openAndAddProject(filepath));
}
@@ -1002,7 +1014,7 @@ bool QETDiagramEditor::openAndAddProject(
bool interactive)
{
if (filepath.isEmpty()) return(false);
-
+
QFileInfo filepath_info(filepath);
//Check if project is not open in another editor
@@ -1024,7 +1036,7 @@ bool QETDiagramEditor::openAndAddProject(
return(diagram_editor -> openAndAddProject(filepath));
}
}
-
+
// check the file exists
if (!filepath_info.exists())
{
@@ -1056,7 +1068,7 @@ bool QETDiagramEditor::openAndAddProject(
}
return(false);
}
-
+
//Check if file is read only
if (!filepath_info.isWritable())
{
@@ -1070,10 +1082,10 @@ bool QETDiagramEditor::openAndAddProject(
);
}
}
-
+
//Create the project
DialogWaiting::instance(this);
-
+
QETProject *project = new QETProject(filepath);
if (project -> state() != QETProject::Ok)
{
@@ -1120,14 +1132,14 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel)
undo_group.addStack(project -> undoStack());
m_element_collection_widget->addProject(project);
-
+
// met a jour le panel d'elements
if (update_panel) {
pa -> elementsPanel().projectWasOpened(project);
if (currentDiagramView() != nullptr)
m_autonumbering_dock->setProject(project, project_view);
}
-
+
return(true);
}
@@ -1154,10 +1166,10 @@ ProjectView *QETDiagramEditor::currentProjectView() const
{
QMdiSubWindow *current_window = m_workspace.activeSubWindow();
if (!current_window) return(nullptr);
-
+
QWidget *current_widget = current_window -> widget();
if (!current_widget) return(nullptr);
-
+
if (ProjectView *project_view = qobject_cast(current_widget)) {
return(project_view);
}
@@ -1203,11 +1215,11 @@ Element *QETDiagramEditor::currentElement() const
DiagramView *dv = currentDiagramView();
if (!dv)
return(nullptr);
-
+
QList selected_elements = DiagramContent(dv->diagram()).m_elements;
if (selected_elements.count() != 1)
return(nullptr);
-
+
return(selected_elements.first());
}
@@ -1426,7 +1438,7 @@ void QETDiagramEditor::selectionGroupTriggered(QAction *action)
QList deti_list = dc.m_element_texts.values();
if(deti_list.size() <= 1)
return;
-
+
diagram->undoStack().push(new AddTextsGroupCommand(deti_list.first()->parentElement(), tr("Groupe"), deti_list));
}
}
@@ -1441,7 +1453,7 @@ void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
Diagram *d = dv->diagram();
BorderProperties old_bp = d->border_and_titleblock.exportBorder();
BorderProperties new_bp = d->border_and_titleblock.exportBorder();
-
+
if (value == "add_column")
new_bp.columns_count += 1;
else if (value == "remove_column")
@@ -1450,7 +1462,7 @@ void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
new_bp.rows_count += 1;
else if (value == "remove_row")
new_bp.rows_count -= 1;
-
+
d->undoStack().push(new ChangeBorderCommand(d, old_bp, new_bp));
}
@@ -1542,23 +1554,23 @@ void QETDiagramEditor::slot_updateComplexActions()
<< m_group_selected_texts;
for(QAction *action : action_list)
action->setEnabled(false);
-
+
return;
}
-
+
Diagram *diagram_ = dv->diagram();
DiagramContent dc(diagram_);
bool ro = diagram_->isReadOnly();
-
+
//Number of selected conductors
int selected_conductors_count = diagram_->selectedConductors().count();
m_conductor_reset->setEnabled(!ro && selected_conductors_count);
-
+
// number of selected elements
int selected_elements_count = dc.count(DiagramContent::Elements);
m_find_element->setEnabled(selected_elements_count == 1);
-
+
//Action that need items (elements, conductors, texts...) selected, to be enabled
bool copiable_items = dc.hasCopiableItems();
bool deletable_items = dc.hasDeletableItems();
@@ -1584,7 +1596,7 @@ void QETDiagramEditor::slot_updateComplexActions()
selected_dynamic_elmt_text++;
}
m_rotate_texts->setEnabled(!ro && (selected_texts || groups.size()));
-
+
//Action that need only element text selected
QList deti_list = dc.m_element_texts.values();
if(deti_list.size() > 1 && dc.count() == deti_list.count())
@@ -1653,7 +1665,7 @@ void QETDiagramEditor::slot_updateComplexActions()
m_edit_selection -> setIcon(QET::Icons::ElementEdit);
m_edit_selection -> setEnabled(false);
}
-
+
//Actions for edit Z value
QList list = dc.items(
DiagramContent::SelectedOnly
@@ -1670,7 +1682,7 @@ void QETDiagramEditor::slot_updateComplexActions()
void QETDiagramEditor::slot_updateModeActions()
{
DiagramView *dv = currentDiagramView();
-
+
if (!dv)
grp_visu_sel -> setEnabled(false);
else
@@ -1708,7 +1720,7 @@ void QETDiagramEditor::slot_updatePasteAction()
{
DiagramView *dv = currentDiagramView();
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
-
+
// pour coller, il faut un schema ouvert et un schema dans le presse-papier
m_paste -> setEnabled(editable_diagram && Diagram::clipboardMayContainDiagram());
}
@@ -1725,7 +1737,7 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
foreach(DiagramView *dv, project_view -> diagram_views())
diagramWasAdded(dv);
-
+
//Manage the close event of project
connect(project_view, SIGNAL(projectClosed(ProjectView*)),
this, SLOT(projectWasClosed(ProjectView *)));
@@ -1736,13 +1748,13 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
if (QETProject *project = project_view -> project())
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)),
this, SLOT(slot_updateActions()));
-
+
//Manage request for edit or find element and titleblock
connect (project_view, &ProjectView::findElementRequired,
this, &QETDiagramEditor::findElementInPanel);
connect (project_view, &ProjectView::editElementRequired,
this, &QETDiagramEditor::editElementInEditor);
-
+
// display error messages sent by the project view
connect(project_view, SIGNAL(errorEncountered(QString)),
this, SLOT(showError(const QString &)));
@@ -1757,7 +1769,7 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
QMdiSubWindow *sub_window = m_workspace.addSubWindow(project_view);
sub_window -> setWindowIcon(project_view -> windowIcon());
sub_window -> systemMenu() -> clear();
-
+
//By defaut QMdiSubWindow have a QAction "close" with shortcut QKeySequence::Close
//But the QAction m_close_file of this class have the same shortcut too.
//We remove the shortcut of the QAction of QMdiSubWindow for avoid conflic
@@ -1796,7 +1808,7 @@ QList QETDiagramEditor::editedFiles() const
ProjectView *QETDiagramEditor::viewForFile(const QString &filepath) const
{
if (filepath.isEmpty()) return(nullptr);
-
+
QString searched_can_file_path = QFileInfo(filepath).canonicalFilePath();
if (searched_can_file_path.isEmpty()) {
// QFileInfo returns an empty path for non-existent files
@@ -1858,29 +1870,29 @@ void QETDiagramEditor::slot_updateWindowsMenu()
{
// nettoyage du menu
foreach(QAction *a, windows_menu -> actions()) windows_menu -> removeAction(a);
-
+
// actions de fermeture
windows_menu -> addAction(m_close_file);
//windows_menu -> addAction(closeAllAct);
-
+
// actions de reorganisation des fenetres
windows_menu -> addSeparator();
windows_menu -> addAction(m_tile_window);
windows_menu -> addAction(m_cascade_window);
-
+
// actions de deplacement entre les fenetres
windows_menu -> addSeparator();
windows_menu -> addAction(m_next_window);
windows_menu -> addAction(m_previous_window);
-
+
// liste des fenetres
QList windows = openedProjects();
-
+
m_tile_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
m_cascade_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
m_next_window -> setEnabled(windows.count() > 1);
m_previous_window -> setEnabled(windows.count() > 1);
-
+
if (!windows.isEmpty()) windows_menu -> addSeparator();
QActionGroup *windows_actions = new QActionGroup(this);
foreach(ProjectView *project_view, windows) {
@@ -1946,15 +1958,15 @@ void QETDiagramEditor::setTabbedMode()
void QETDiagramEditor::readSettings()
{
QSettings settings;
-
+
// dimensions et position de la fenetre
QVariant geometry = settings.value("diagrameditor/geometry");
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
-
+
// etat de la fenetre (barres d'outils, docks...)
QVariant state = settings.value("diagrameditor/state");
if (state.isValid()) restoreState(state.toByteArray());
-
+
// gestion des projets (onglets ou fenetres)
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
if (tabbed) {
@@ -2018,7 +2030,7 @@ void QETDiagramEditor::activateProject(ProjectView *project_view)
void QETDiagramEditor::projectWasClosed(ProjectView *project_view)
{
QETProject *project = project_view -> project();
- if (project)
+ if (project)
{
pa -> elementsPanel().projectWasClosed(project);
m_element_collection_widget->removeProject(project);
@@ -2064,7 +2076,7 @@ void QETDiagramEditor::addDiagramToProject(QETProject *project)
if (!project) {
return;
}
-
+
if (ProjectView *project_view = findProject(project))
{
activateProject(project);
@@ -2079,15 +2091,15 @@ void QETDiagramEditor::addDiagramToProject(QETProject *project)
void QETDiagramEditor::removeDiagram(Diagram *diagram)
{
if (!diagram) return;
-
+
// recupere le projet contenant le schema
if (QETProject *diagram_project = diagram -> project()) {
// recupere la vue sur ce projet
if (ProjectView *project_view = findProject(diagram_project)) {
-
+
// affiche le schema en question
project_view -> showDiagram(diagram);
-
+
// supprime le schema
project_view -> removeDiagram(diagram);
}
@@ -2102,11 +2114,11 @@ void QETDiagramEditor::removeDiagram(Diagram *diagram)
void QETDiagramEditor::moveDiagramUp(Diagram *diagram)
{
if (!diagram) return;
-
+
// recupere le projet contenant le schema
if (QETProject *diagram_project = diagram -> project()) {
if (diagram_project -> isReadOnly()) return;
-
+
// recupere la vue sur ce projet
if (ProjectView *project_view = findProject(diagram_project)) {
project_view -> moveDiagramUp(diagram);
@@ -2122,11 +2134,11 @@ void QETDiagramEditor::moveDiagramUp(Diagram *diagram)
void QETDiagramEditor::moveDiagramDown(Diagram *diagram)
{
if (!diagram) return;
-
+
// recupere le projet contenant le schema
if (QETProject *diagram_project = diagram -> project()) {
if (diagram_project -> isReadOnly()) return;
-
+
// recupere la vue sur ce projet
if (ProjectView *project_view = findProject(diagram_project)) {
project_view -> moveDiagramDown(diagram);
@@ -2313,7 +2325,7 @@ void QETDiagramEditor::generateTerminalBlock()
{
bool success;
QProcess *process = new QProcess(qApp);
-
+
// If launched under control:
//connect(process, SIGNAL(errorOcurred(int error)), this, SLOT(slot_generateTerminalBlock_error()));
//process->start("qet_tb_generator");
@@ -2351,7 +2363,7 @@ void QETDiagramEditor::generateTerminalBlock()
else {
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {("")});
}
-
+
#else
if (openedProjects().count()){
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
@@ -2365,7 +2377,7 @@ void QETDiagramEditor::generateTerminalBlock()
else {
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {("")});
}
-
+
#endif
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
QString message=QObject::tr(
diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h
index 9de7db721..9e7ce75e2 100644
--- a/sources/qetgraphicsitem/element.h
+++ b/sources/qetgraphicsitem/element.h
@@ -1,23 +1,27 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#ifndef ELEMENT_H
#define ELEMENT_H
+#include
+#include
+#include
+
#include "qet.h"
#include "qetgraphicsitem.h"
#include "diagramcontext.h"
@@ -25,9 +29,6 @@
#include "elementslocation.h"
#include "nameslist.h"
-#include
-#include
-
class QETProject;
class Terminal;
class Conductor;
@@ -40,7 +41,7 @@ class ElementTextItemGroup;
class Element : public QetGraphicsItem
{
friend class DiagramEventAddElement;
-
+
Q_OBJECT
public:
/**
@@ -64,7 +65,7 @@ class Element : public QetGraphicsItem
~Element() override;
private:
Element(const Element &);
-
+
// attributes
public:
/**
@@ -74,7 +75,7 @@ class Element : public QetGraphicsItem
*/
enum { Type = UserType + 1000 };
int type() const override { return Type; }
-
+
signals:
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
void elementInfoChange(
@@ -91,12 +92,12 @@ class Element : public QetGraphicsItem
DynamicElementTextItem *text,
ElementTextItemGroup *group);
-
+
public:
QList terminals() const;
QList conductors() const;
QList> AlignedFreeTerminals() const;
-
+
//METHODS related to information
DiagramContext elementInformations()const
{return m_element_informations;}
@@ -118,7 +119,7 @@ class Element : public QetGraphicsItem
bool isFreezeLabel() const {return m_freeze_label;}
void freezeNewAddedElement();
QString actualLabel();
-
+
QString name() const override;
ElementsLocation location() const;
virtual void setHighlighted(bool);
@@ -140,7 +141,7 @@ class Element : public QetGraphicsItem
int> &) const;
QUuid uuid() const;
int orientation() const;
-
+
//METHODS related to texts
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
void removeDynamicTextItem(DynamicElementTextItem *deti);
@@ -156,7 +157,7 @@ class Element : public QetGraphicsItem
bool removeTextFromGroup(
DynamicElementTextItem *text,
ElementTextItemGroup *group);
-
+
//METHODS related to linked element
bool isFree() const;
virtual void linkToElement(Element *) {}
@@ -171,7 +172,7 @@ class Element : public QetGraphicsItem
protected:
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
void setSize(int, int);
-
+
private:
void drawSelection(
QPainter *,
@@ -212,25 +213,25 @@ class Element : public QetGraphicsItem
// to be use in the function element::fromXml
QHash
m_converted_text_from_xml_description;
-
+
//ATTRIBUTES related to linked element
QList connected_elements;
QList tmp_uuids_link;
QUuid m_uuid;
kind m_link_type = Element::Simple;
-
+
//ATTRIBUTES related to informations
DiagramContext m_element_informations, m_kind_informations;
autonum::sequentialNumbers m_autoNum_seq;
bool m_freeze_label = false;
QString m_F_str;
-
+
ElementsLocation m_location;
NamesList m_names;
QList m_terminals;
const QPicture m_picture;
const QPicture m_low_zoom_picture;
-
+
private:
bool m_must_highlight = false;
QSize dimensions;
diff --git a/sources/qetgraphicsitem/qetshapeitem.cpp b/sources/qetgraphicsitem/qetshapeitem.cpp
index 89f99b90e..adac49f45 100644
--- a/sources/qetgraphicsitem/qetshapeitem.cpp
+++ b/sources/qetgraphicsitem/qetshapeitem.cpp
@@ -965,30 +965,28 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
switch (m_shapeType)
{
case Line:
- Createdxf::drawLine(filepath,
- QLineF(mapToScene(m_P1),
- mapToScene(m_P2)),
- Createdxf::getcolorCode(pen.color().red(),
- pen.color().green(),
- pen.color().blue()));
- return true;
+ Createdxf::drawLine(filepath,
+ QLineF( mapToScene(m_P1),
+ mapToScene(m_P2)),
+ Createdxf::dxfColor(pen));
+ return true;
case Rectangle:
- Createdxf::drawRectangle(filepath,
- QRectF(mapToScene(m_P1),
- mapToScene(m_P2)).normalized(),
- Createdxf::getcolorCode(pen.color().red(),
- pen.color().green(),
- pen.color().blue()));
- return true;
+ Createdxf::drawRectangle(filepath,
+ QRectF(mapToScene(m_P1),
+ mapToScene(m_P2)).normalized(),
+ Createdxf::dxfColor(pen));
+ return true;
case Ellipse:
- Createdxf::drawEllipse (filepath,
- QRectF(mapToScene(m_P1),
- mapToScene(m_P2)).normalized(),
- Createdxf::getcolorCode(pen.color().red(),
- pen.color().green(),
- pen.color().blue()));
- return true;
- default: return false;
+ Createdxf::drawEllipse(filepath,
+ QRectF(mapToScene(m_P1),
+ mapToScene(m_P2)).normalized(),
+ Createdxf::dxfColor(pen));
+ return true;
+ case Polygon:
+ Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
+ return true;
+ default:
+ return false;
}
}
diff --git a/sources/qetinformation.cpp b/sources/qetinformation.cpp
index 7af614854..4ff4a6de9 100644
--- a/sources/qetinformation.cpp
+++ b/sources/qetinformation.cpp
@@ -1,25 +1,26 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
-#include "qetinformation.h"
#include
#include
+#include "qetinformation.h"
+
/**
@brief QETInformation::titleblockInfoKeys
@return all available key for use with a titleblock
@@ -47,7 +48,7 @@ QStringList QETInformation::titleblockInfoKeys()
info_list << "savedtime";
info_list << "savedfilename";
info_list << "savedfilepath";
-
+
return info_list;
}
diff --git a/sources/qetinformation.h b/sources/qetinformation.h
index ee8f25de0..b2dcebd12 100644
--- a/sources/qetinformation.h
+++ b/sources/qetinformation.h
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -19,6 +19,7 @@
#define QETINFORMATION_H
#include
+#include
namespace QETInformation
{
diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp
index f1599b864..1894d8c6d 100644
--- a/sources/qetproject.cpp
+++ b/sources/qetproject.cpp
@@ -1,20 +1,27 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
+
+#include
+#include
+#include
+#include
+#include
+
#include "qetproject.h"
#include "diagram.h"
#include "qetapp.h"
@@ -30,11 +37,6 @@
#include "numerotationcontextcommands.h"
#include "assignvariables.h"
-#include
-#include
-#include
-#include
-
static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
/**
@@ -279,7 +281,7 @@ void QETProject::setFilePath(const QString &filepath)
m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath));
m_file_path = filepath;
-
+
QFileInfo fi(m_file_path);
if (fi.isWritable()) {
setReadOnly(false);
@@ -290,9 +292,9 @@ void QETProject::setFilePath(const QString &filepath)
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
m_project_properties.addValue("savedfilepath", filePath());
-
-
-
+
+
+
emit(projectFilePathChanged(this, m_file_path));
emit(projectInformationsChanged(this));
updateDiagramsFolioData();
@@ -315,7 +317,7 @@ QString QETProject::currentDir() const
}
/**
-
+
@return une chaine de caractere du type "Projet titre du projet".
Si le projet n'a pas de titre, le nom du fichier est utilise.
Si le projet n'est pas associe a un fichier, cette methode retourne "Projet
@@ -326,7 +328,7 @@ QString QETProject::currentDir() const
QString QETProject::pathNameTitle() const
{
QString final_title;
-
+
if (!project_title_.isEmpty()) {
final_title = QString(
tr(
@@ -349,7 +351,7 @@ QString QETProject::pathNameTitle() const
)
);
}
-
+
if (isReadOnly()) {
final_title = QString(
tr(
@@ -366,7 +368,7 @@ QString QETProject::pathNameTitle() const
)
).arg(final_title);
}
-
+
return(final_title);
}
@@ -394,10 +396,10 @@ qreal QETProject::declaredQElectroTechVersion()
void QETProject::setTitle(const QString &title) {
// ne fait rien si le projet est en lecture seule
if (isReadOnly()) return;
-
+
// ne fait rien si le titre du projet n'est pas change par l'appel de cette methode
if (project_title_ == title) return;
-
+
project_title_ = title;
emit(projectTitleChanged(this, project_title_));
emit(projectInformationsChanged(this));
@@ -487,7 +489,7 @@ void QETProject::setDefaultReportProperties(const QString &properties)
{
QString old = m_default_report_properties;
m_default_report_properties = properties;
-
+
emit reportPropertiesChanged(old, properties);
}
@@ -856,7 +858,7 @@ QDomDocument QETProject::toXml()
project_root.setAttribute("version", QET::version);
project_root.setAttribute("title", project_title_);
xml_doc.appendChild(project_root);
-
+
// titleblock templates, if any
if (m_titleblocks_collection.templates().count()) {
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
@@ -866,19 +868,19 @@ QDomDocument QETProject::toXml()
}
project_root.appendChild(titleblocktemplates_elmt);
}
-
+
// project-wide properties
QDomElement project_properties = xml_doc.createElement("properties");
writeProjectPropertiesXml(project_properties);
project_root.appendChild(project_properties);
-
+
// Properties for news diagrams
QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
writeDefaultPropertiesXml(new_diagrams_properties);
project_root.appendChild(new_diagrams_properties);
-
+
// schemas
-
+
qDebug() << "Export XML de" << m_diagrams_list.count() << "schemas";
int order_num = 1;
const QList diagrams_list = m_diagrams_list;
@@ -895,10 +897,10 @@ QDomDocument QETProject::toXml()
QDomNode appended_diagram = project_root.appendChild(xml_node);
appended_diagram.toElement().setAttribute("order", order_num ++);
}
-
+
// Write the elements collection.
project_root.appendChild(m_elements_collection->root().cloneNode(true));
-
+
return(xml_doc);
}
@@ -932,16 +934,20 @@ QETResult QETProject::write()
QString error_message;
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message))
return(error_message);
-
+
//title block variables should be updated after file save dialog is confirmed, before file is saved.
- m_project_properties.addValue("saveddate", QDate::currentDate().toString(Qt::SystemLocaleShortDate));
+ m_project_properties.addValue(
+ "saveddate",
+ QDate::currentDate().toString(
+ QLocale::system().toString(
+ QLocale::ShortFormat)));
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
m_project_properties.addValue("savedfilepath", filePath());
-
- emit(projectInformationsChanged(this));
- updateDiagramsFolioData();
-
+
+ emit(projectInformationsChanged(this));
+ updateDiagramsFolioData();
+
setModified(false);
return(QETResult());
}
@@ -981,15 +987,15 @@ bool QETProject::isEmpty() const
{
// si le projet a un titre, on considere qu'il n'est pas vide
if (!project_title_.isEmpty()) return(false);
-
+
//@TODO check if the embedded element collection is empty
-
+
// compte le nombre de schemas non vides
int pertinent_diagrams = 0;
foreach(Diagram *diagram, m_diagrams_list) {
if (!diagram -> isEmpty()) ++ pertinent_diagrams;
}
-
+
return(pertinent_diagrams > 0);
}
@@ -1089,13 +1095,13 @@ ElementsLocation QETProject::importElement(ElementsLocation &location)
Integrate a title block template into this project.
@param src_tbt The location of the title block template
to be integrated into this project
- @param handler
+ @param handler
@return the name of the template after integration,
or an empty QString if a problem occurred.
*/
QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation &src_tbt, MoveTitleBlockTemplatesHandler *handler) {
TitleBlockTemplateLocation dst_tbt(src_tbt.name(), &m_titleblocks_collection);
-
+
// check whether a TBT having the same name already exists within this project
QString target_name = dst_tbt.name();
while (m_titleblocks_collection.templates().contains(target_name))
@@ -1113,7 +1119,7 @@ QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation
return(target_name);
}
}
-
+
if (!m_titleblocks_collection.setTemplateXmlDescription(target_name, src_tbt.getTemplateXmlDescription()))
{
handler -> errorWithATemplate(src_tbt, tr("Une erreur s'est produite durant l'intégration du modèle.", "error message"));
@@ -1164,7 +1170,7 @@ QList QETProject::unusedElements() const
bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &location) {
// a diagram can only use a title block template embedded wihtin its parent project
if (location.parentProject() != this) return(false);
-
+
foreach (Diagram *diagram, diagrams()) {
if (diagram -> usesTitleBlockTemplate(location.name())) {
return(true);
@@ -1184,9 +1190,9 @@ Diagram *QETProject::addNewDiagram(int pos)
if (isReadOnly()) {
return(nullptr);
}
-
+
Diagram *diagram = new Diagram(this);
-
+
diagram->border_and_titleblock.importBorder(defaultBorderProperties());
diagram->border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
diagram->defaultConductorProperties = defaultConductorProperties();
@@ -1214,7 +1220,7 @@ void QETProject::removeDiagram(Diagram *diagram)
emit(diagramRemoved(this, diagram));
diagram->deleteLater();
}
-
+
updateDiagramsFolioData();
}
@@ -1228,10 +1234,10 @@ void QETProject::removeDiagram(Diagram *diagram)
*/
void QETProject::diagramOrderChanged(int old_index, int new_index) {
if (old_index < 0 || new_index < 0) return;
-
+
int diagram_max_index = m_diagrams_list.size() - 1;
if (old_index > diagram_max_index || new_index > diagram_max_index) return;
-
+
m_diagrams_list.move(old_index, new_index);
updateDiagramsFolioData();
setModified(true);
@@ -1258,7 +1264,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
{
QDomElement root_elmt = xml_project.documentElement();
m_state = ProjectParsingRunning;
-
+
//The roots of the xml document must be a "project" element
if (root_elmt.tagName() == "project")
{
@@ -1282,7 +1288,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
"message box content"),
QMessageBox::Open | QMessageBox::Cancel
);
-
+
if (ret == QMessageBox::Cancel)
{
m_state = FileOpenDiscard;
@@ -1296,7 +1302,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
{
m_state = ProjectParsingFailed;
}
-
+
m_data_base.blockSignals(true);
//Load the project-wide properties
readProjectPropertiesXml(xml_project);
@@ -1310,7 +1316,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
readDiagramsXml(xml_project);
m_data_base.blockSignals(false);
m_data_base.updateDB();
-
+
m_state = Ok;
}
@@ -1336,18 +1342,18 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project)
"Création des folios"
"
"));
}
-
+
//Search the diagrams in the project
QDomNodeList diagram_nodes = xml_project.elementsByTagName("diagram");
-
+
if(dlgWaiting)
dlgWaiting->setProgressBarRange(0, diagram_nodes.length()*3);
-
+
for (int i = 0 ; i < diagram_nodes.length() ; ++ i)
{
if(dlgWaiting)
dlgWaiting->setProgressBar(i+1);
-
+
if (diagram_nodes.at(i).isElement())
{
QDomElement diagram_xml_element = diagram_nodes
@@ -1543,17 +1549,17 @@ void QETProject::writeProjectPropertiesXml(QDomElement &xml_element) {
void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
{
QDomDocument xml_document = xml_element.ownerDocument();
-
+
// export size of border
QDomElement border_elmt = xml_document.createElement("border");
default_border_properties_.toXml(border_elmt);
xml_element.appendChild(border_elmt);
-
+
// export content of titleblock
QDomElement titleblock_elmt = xml_document.createElement("inset");
default_titleblock_properties_.toXml(titleblock_elmt);
xml_element.appendChild(titleblock_elmt);
-
+
// exporte default conductor
QDomElement conductor_elmt = xml_document.createElement("conductors");
default_conductor_properties_.toXml(conductor_elmt);
@@ -1728,7 +1734,7 @@ bool QETProject::projectWasModified()
!m_undo_stack -> isClean() ||
m_titleblocks_collection.templates().count() )
return(true);
-
+
else
return(false);
}
@@ -1740,19 +1746,19 @@ bool QETProject::projectWasModified()
void QETProject::updateDiagramsFolioData()
{
int total_folio = m_diagrams_list.count();
-
+
DiagramContext project_wide_properties = m_project_properties;
project_wide_properties.addValue("projecttitle", title());
project_wide_properties.addValue("projectpath", filePath());
project_wide_properties.addValue("projectfilename", QFileInfo(filePath()).baseName());
-
+
for (int i = 0 ; i < total_folio ; ++ i)
{
QString autopagenum = m_diagrams_list[i]->border_and_titleblock.autoPageNum();
NumerotationContext nC = folioAutoNum(autopagenum);
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
-
- if ((m_diagrams_list[i]->border_and_titleblock.folio().contains("%autonum")) &&
+
+ if ((m_diagrams_list[i]->border_and_titleblock.folio().contains("%autonum")) &&
(!autopagenum.isNull()))
{
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties);
@@ -1761,12 +1767,12 @@ void QETProject::updateDiagramsFolioData()
else {
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nullptr, project_wide_properties);
}
-
+
if (i > 0)
{
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(m_diagrams_list.at(i-1)->border_and_titleblock.finalfolio());
m_diagrams_list.at(i-1)->border_and_titleblock.setNextFolioNum(m_diagrams_list.at(i)->border_and_titleblock.finalfolio());
-
+
if (i == total_folio-1) {
m_diagrams_list.at(i)->border_and_titleblock.setNextFolioNum(QString());
}
@@ -1775,7 +1781,7 @@ void QETProject::updateDiagramsFolioData()
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(QString());
}
}
-
+
for (Diagram *d : m_diagrams_list) {
d->update();
}
@@ -1788,7 +1794,7 @@ void QETProject::updateDiagramsFolioData()
*/
void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
Q_UNUSED(collection)
-
+
foreach (Diagram *diagram, m_diagrams_list) {
diagram -> titleBlockTemplateChanged(template_name);
}
@@ -1801,7 +1807,7 @@ void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection
*/
void QETProject::removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
Q_UNUSED(collection)
-
+
// warn diagrams that the given template is about to be removed
foreach (Diagram *diagram, m_diagrams_list) {
diagram -> titleBlockTemplateRemoved(template_name);
diff --git a/sources/qetproject.h b/sources/qetproject.h
index 00e39ec58..49eb07974 100644
--- a/sources/qetproject.h
+++ b/sources/qetproject.h
@@ -1,23 +1,26 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#ifndef QET_PROJECT_H
#define QET_PROJECT_H
+#include
+#include
+
#include "nameslist.h"
#include "elementslocation.h"
#include "borderproperties.h"
@@ -28,8 +31,6 @@
#include "projectdatabase.h"
#include "reportproperties.h"
-#include
-
class Diagram;
class ElementsLocation;
class QETResult;
@@ -62,7 +63,7 @@ class QETProject : public QObject
};
Q_PROPERTY(bool autoConductor READ autoConductor WRITE setAutoConductor)
-
+
// constructors, destructor
public:
QETProject (QObject *parent = nullptr);
@@ -72,7 +73,7 @@ class QETProject : public QObject
private:
QETProject(const QETProject &);
-
+
// methods
public:
projectDataBase *dataBase();
@@ -166,13 +167,13 @@ class QETProject : public QObject
DiagramContext projectProperties();
void setProjectProperties(const DiagramContext &);
QUndoStack* undoStack() {return m_undo_stack;}
-
+
public slots:
Diagram *addNewDiagram(int pos = -1);
void removeDiagram(Diagram *);
void diagramOrderChanged(int, int);
void setModified(bool);
-
+
signals:
void projectFilePathChanged(QETProject *, const QString &);
void projectTitleChanged(QETProject *, const QString &);
@@ -195,14 +196,14 @@ class QETProject : public QObject
void folioAutoNumChanged(QString);
void defaultTitleBlockPropertiesChanged();
void conductorAutoNumChanged();
-
+
private slots:
void updateDiagramsFolioData();
void updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
void removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *, const QString &);
void usedTitleBlockTemplateChanged(const QString &);
void undoStackChanged (bool a) {if (!a) setModified(true);}
-
+
private:
void readProjectXml(QDomDocument &xml_project);
void readDiagramsXml(QDomDocument &xml_project);
@@ -217,7 +218,7 @@ class QETProject : public QObject
void writeBackup();
void init();
ProjectState openFile(QFile *file);
-
+
// attributes
private:
/// File path this project is saved to
diff --git a/sources/qetregexpvalidator.cpp b/sources/qetregexpvalidator.cpp
index d6c01b3fb..e4f409b3f 100644
--- a/sources/qetregexpvalidator.cpp
+++ b/sources/qetregexpvalidator.cpp
@@ -1,27 +1,30 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#include "qetregexpvalidator.h"
+#include
/**
Constructeur
@param parent QObject parent
*/
-QETRegExpValidator::QETRegExpValidator(QObject *parent) : QRegExpValidator(parent) {
+QETRegExpValidator::QETRegExpValidator(QObject *parent)
+ : QRegularExpressionValidator(parent)
+{
}
/**
@@ -29,7 +32,10 @@ QETRegExpValidator::QETRegExpValidator(QObject *parent) : QRegExpValidator(paren
@param regexp Expression reguliere a valider
@param parent QObject parent
*/
-QETRegExpValidator::QETRegExpValidator(const QRegExp ®exp, QObject *parent) : QRegExpValidator(regexp, parent) {
+QETRegExpValidator::QETRegExpValidator(
+ const QRegularExpression ®exp, QObject *parent) :
+ QRegularExpressionValidator(regexp, parent)
+{
}
/**
@@ -40,13 +46,15 @@ QETRegExpValidator::~QETRegExpValidator()
}
/**
- @see QRegExpValidator::validate
+ @see QRegularExpressionValidator::validate
@see validationFailed()
Emet le signal validationFailed si la validation echoue
*/
QValidator::State QETRegExpValidator::validate(QString &input, int &pos) const
{
- QValidator::State result = QRegExpValidator::validate(input, pos);
- if (result == QValidator::Invalid) emit(validationFailed());
+ QValidator::State result = QRegularExpressionValidator::validate(
+ input, pos);
+ if (result == QValidator::Invalid)
+ emit(validationFailed());
return(result);
}
diff --git a/sources/qetregexpvalidator.h b/sources/qetregexpvalidator.h
index d11981ff4..4224112b1 100644
--- a/sources/qetregexpvalidator.h
+++ b/sources/qetregexpvalidator.h
@@ -1,42 +1,42 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#ifndef QET_REGEXP_VALIDATOR_H
#define QET_REGEXP_VALIDATOR_H
-#include
+#include
/**
- This class acts like a QRegExpValidator except it emits a signal when the
- input validation fails.
+ This class acts like a QRegularExpressionValidator
+ except it emits a signal when the input validation fails.
*/
-class QETRegExpValidator : public QRegExpValidator {
+class QETRegExpValidator : public QRegularExpressionValidator {
Q_OBJECT
-
+
// constructors, destructor
public:
QETRegExpValidator(QObject *);
- QETRegExpValidator(const QRegExp &, QObject *);
+ QETRegExpValidator(const QRegularExpression &, QObject *);
~QETRegExpValidator() override;
private:
QETRegExpValidator(const QETRegExpValidator &);
-
+
// methods
public:
QValidator::State validate(QString &, int &) const override;
-
+
signals:
void validationFailed() const;
};
diff --git a/sources/qfilenameedit.cpp b/sources/qfilenameedit.cpp
index 918329713..2999ba829 100644
--- a/sources/qfilenameedit.cpp
+++ b/sources/qfilenameedit.cpp
@@ -1,24 +1,24 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#include "qfilenameedit.h"
#include "qetregexpvalidator.h"
#include
-#include
+#include
#include
/**
@@ -36,7 +36,7 @@ QFileNameEdit::QFileNameEdit(QWidget *parent) : QLineEdit(parent) {
*/
QFileNameEdit::QFileNameEdit(const QString &contents, QWidget *parent) : QLineEdit(parent) {
init();
- if (!contents.isEmpty() && regexp_.exactMatch(contents)) {
+ if (!contents.isEmpty() && regexp_==QRegularExpression(contents)) {
setText(contents);
}
}
@@ -61,7 +61,7 @@ bool QFileNameEdit::isEmpty()
*/
bool QFileNameEdit::isValid()
{
- return(regexp_.exactMatch(text()));
+ return(regexp_==QRegularExpression(text()));
}
/**
@@ -69,7 +69,7 @@ bool QFileNameEdit::isValid()
*/
void QFileNameEdit::init()
{
- regexp_ = QRegExp("^[0-9a-z_\\-\\.]+$", Qt::CaseSensitive);
+ regexp_ = QRegularExpression("^[0-9a-z_\\-\\.]+$");
validator_ = new QETRegExpValidator(regexp_, this);
setValidator(validator_);
tooltip_text_ = QString(
diff --git a/sources/qfilenameedit.h b/sources/qfilenameedit.h
index 5d5ca8fc2..c688e1a8b 100644
--- a/sources/qfilenameedit.h
+++ b/sources/qfilenameedit.h
@@ -1,25 +1,25 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#ifndef Q_FILENAME_EDIT_H
#define Q_FILENAME_EDIT_H
#include
-#include
#include
+#include
class QETRegExpValidator;
/**
This class represents a textfield dedicated to input a portable filename (not
@@ -31,7 +31,7 @@ class QETRegExpValidator;
*/
class QFileNameEdit : public QLineEdit {
Q_OBJECT
-
+
// constructors, destructor
public:
QFileNameEdit(QWidget * = nullptr);
@@ -39,22 +39,22 @@ class QFileNameEdit : public QLineEdit {
~QFileNameEdit() override;
private:
QFileNameEdit(const QFileNameEdit &);
-
+
// methods
public:
bool isEmpty();
bool isValid();
-
+
private:
void init();
void displayToolTip();
-
+
private slots:
void validationFailed();
-
+
// attributes
private:
- QRegExp regexp_;
+ QRegularExpression regexp_;
QETRegExpValidator *validator_;
QString tooltip_text_;
};
diff --git a/sources/titleblock/qettemplateeditor.cpp b/sources/titleblock/qettemplateeditor.cpp
index f6cb218cd..2a3d48146 100644
--- a/sources/titleblock/qettemplateeditor.cpp
+++ b/sources/titleblock/qettemplateeditor.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -40,7 +40,7 @@ QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor(QWidget *parent) :
{
setWindowIcon(QET::Icons::QETLogo);
setAttribute(Qt::WA_DeleteOnClose);
-
+
initWidgets();
initActions();
initMenus();
@@ -74,7 +74,7 @@ bool QETTitleBlockTemplateEditor::isEditing(const QString &filepath)
} else {
current_filepath = QETApp::realPath(location_.toString());
}
-
+
return(
QET::compareCanonicalFilePaths(
current_filepath,
@@ -166,7 +166,7 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation()
{
// this method does not work for templates edited from the filesystem
if (opened_from_file_) return;
-
+
QString proposed_name;
if (location_.name().isEmpty()) {
proposed_name = tr("nouveau_modele",
@@ -174,7 +174,7 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation()
} else {
proposed_name = QString("%1_copy").arg(location_.name());
}
-
+
bool accepted = false;
QString new_template_name = QInputDialog::getText(
this,
@@ -212,7 +212,7 @@ bool QETTitleBlockTemplateEditor::edit(
/// TODO The TBT does not exist, manage error
return(false);
}
-
+
opened_from_file_ = false;
location_ = location;
setReadOnly(location.isReadOnly());
@@ -231,7 +231,7 @@ bool QETTitleBlockTemplateEditor::edit(
{
// we require a project we will rattach templates to
if (!project) return(false);
-
+
// the template name may be empty to create a new one
const TitleBlockTemplate *tb_template_orig;
if (template_name.isEmpty())
@@ -244,12 +244,12 @@ bool QETTitleBlockTemplateEditor::edit(
{
tb_template_orig = project->embeddedTitleBlockTemplatesCollection()->getTemplate(template_name);
}
-
+
if (!tb_template_orig) {
/// TODO The TBT does not exist, manage error
return(false);
}
-
+
opened_from_file_ = false;
location_.setParentCollection(project -> embeddedTitleBlockTemplatesCollection());
location_.setName(template_name);
@@ -270,13 +270,13 @@ bool QETTitleBlockTemplateEditor::edit(const QString &file_path)
/// TODO the file opening failed, warn the user?
return(false);
}
-
+
bool editing = edit(tbt);
if (!editing) {
/// TODO the file editing failed, warn the user?
return(false);
}
-
+
QFileInfo file_path_info(file_path);
filepath_ = file_path;
opened_from_file_ = true;
@@ -318,20 +318,20 @@ void QETTitleBlockTemplateEditor::editLogos()
if (!logo_manager_) {
initLogoManager();
}
-
+
logo_manager_ -> layout() -> setContentsMargins(0, 0, 0, 0);
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close);
-
+
QVBoxLayout *vlayout0 = new QVBoxLayout();
vlayout0 -> addWidget(logo_manager_);
vlayout0 -> addWidget(buttons);
-
+
QDialog d(this);
d.setWindowTitle(logo_manager_ -> windowTitle());
d.setLayout(vlayout0);
connect(buttons, SIGNAL(rejected()), &d, SLOT(reject()));
d.exec();
-
+
// prevent the logo manager from being deleted along with the dialog
logo_manager_ -> setParent(this);
}
@@ -374,10 +374,10 @@ void QETTitleBlockTemplateEditor::initActions()
add_col_ = new QAction(QET::Icons::EditTableInsertColumnRight, tr("Ajouter une &colonne", "menu entry"), this);
merge_cells_ = new QAction(QET::Icons::EditTableCellMerge, tr("&Fusionner les cellules", "menu entry"), this);
split_cell_ = new QAction(QET::Icons::EditTableCellSplit, tr("&Séparer les cellules", "menu entry"), this);
-
+
undo_ -> setIcon(QET::Icons::EditUndo);
redo_ -> setIcon(QET::Icons::EditRedo);
-
+
new_ -> setShortcut(QKeySequence::New);
open_ -> setShortcut(QKeySequence::Open);
open_from_file_ -> setShortcut(tr("Ctrl+Shift+O", "shortcut to open a template from a file"));
@@ -397,7 +397,7 @@ void QETTitleBlockTemplateEditor::initActions()
zoom_out_ -> setShortcut(QKeySequence::ZoomOut);
zoom_fit_ -> setShortcut(QKeySequence(tr("Ctrl+9", "shortcut to enable fit zoom")));
zoom_reset_ -> setShortcut(QKeySequence(tr("Ctrl+0", "shortcut to reset zoom")));
-
+
connect(new_, SIGNAL(triggered()), this, SLOT(newTemplate()));
connect(open_, SIGNAL(triggered()), this, SLOT(open()));
connect(open_from_file_, SIGNAL(triggered()), this, SLOT(openFromFile()));
@@ -428,7 +428,7 @@ void QETTitleBlockTemplateEditor::initMenus()
file_menu_ = new QMenu(tr("&Fichier", "menu title"), this);
edit_menu_ = new QMenu(tr("&Édition", "menu title"), this);
display_menu_ = new QMenu(tr("Afficha&ge", "menu title"), this);
-
+
file_menu_ -> addAction(new_);
file_menu_ -> addAction(open_);
file_menu_ -> addAction(open_from_file_);
@@ -437,7 +437,7 @@ void QETTitleBlockTemplateEditor::initMenus()
file_menu_ -> addAction(save_as_file_);
file_menu_ -> addSeparator();
file_menu_ -> addAction(quit_);
-
+
edit_menu_ -> addAction(undo_);
edit_menu_ -> addAction(redo_);
edit_menu_ -> addSeparator();
@@ -456,7 +456,7 @@ void QETTitleBlockTemplateEditor::initMenus()
display_menu_ -> addAction(zoom_out_);
display_menu_ -> addAction(zoom_fit_);
display_menu_ -> addAction(zoom_reset_);
-
+
insertMenu(settings_menu_, file_menu_);
insertMenu(settings_menu_, edit_menu_);
insertMenu(settings_menu_, display_menu_);
@@ -474,7 +474,7 @@ void QETTitleBlockTemplateEditor::initToolbars()
main_toolbar -> addAction(save_);
main_toolbar -> addAction(save_as_);
addToolBar(Qt::TopToolBarArea, main_toolbar);
-
+
QToolBar *edit_toolbar = new QToolBar(tr("Édition", "toolbar title"), this);
edit_toolbar -> setObjectName("tbt_edit_toolbar");
edit_toolbar -> addAction(undo_);
@@ -483,7 +483,7 @@ void QETTitleBlockTemplateEditor::initToolbars()
edit_toolbar -> addAction(merge_cells_);
edit_toolbar -> addAction(split_cell_);
addToolBar(Qt::TopToolBarArea, edit_toolbar);
-
+
QToolBar *display_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
display_toolbar -> setObjectName("tbt_display_toolbar");
display_toolbar -> addAction(zoom_in_);
@@ -499,19 +499,22 @@ void QETTitleBlockTemplateEditor::initToolbars()
void QETTitleBlockTemplateEditor::initWidgets()
{
QSettings settings;
-
+
// undo list on the right
undo_stack_ = new QUndoStack(this);
undo_view_ = new QUndoView(undo_stack_);
undo_view_ -> setEmptyLabel(tr("Aucune modification", "label displayed in the undo list when empty"));
-
+
undo_dock_widget_ = new QDockWidget(tr("Annulations", "dock title"));
undo_dock_widget_ -> setObjectName("tbt_undo_dock");
- undo_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures);
+ undo_dock_widget_ -> setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
undo_dock_widget_ -> setWidget(undo_view_);
undo_dock_widget_ -> setMinimumWidth(290);
addDockWidget(Qt::RightDockWidgetArea, undo_dock_widget_);
-
+
// WYSIWYG editor as central widget
template_edition_area_scene_ = new QGraphicsScene(this);
template_edition_area_view_ = new TitleBlockTemplateView(template_edition_area_scene_);
@@ -521,18 +524,21 @@ void QETTitleBlockTemplateEditor::initWidgets()
template_edition_area_view_ -> setPreviewWidth(conf_preview_width);
}
setCentralWidget(template_edition_area_view_);
-
+
// cell edition widget at the bottom
template_cell_editor_widget_ = new TitleBlockTemplateCellWidget(tb_template_);
template_cell_editor_dock_widget_ = new QDockWidget(tr("Propriétés de la cellule", "dock title"), this);
template_cell_editor_dock_widget_ -> setObjectName("tbt_celleditor_dock");
- template_cell_editor_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures);
+ template_cell_editor_dock_widget_ -> setFeatures(
+ QDockWidget::DockWidgetClosable
+ |QDockWidget::DockWidgetMovable
+ |QDockWidget::DockWidgetFloatable);
template_cell_editor_dock_widget_ -> setWidget(template_cell_editor_widget_);
template_cell_editor_dock_widget_ -> setMinimumWidth(180);
template_cell_editor_dock_widget_ -> setMinimumHeight(250);
addDockWidget(Qt::BottomDockWidgetArea, template_cell_editor_dock_widget_);
template_cell_editor_widget_ -> setVisible(false);
-
+
connect(
template_edition_area_view_,
SIGNAL(selectedCellsChanged(QList)),
@@ -592,7 +598,7 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
} else {
titleblock_title = location_.name();
}
-
+
// if a (file)name has been added, also add a "[Changed]" tag if needed
if (!titleblock_title.isEmpty()) {
QString tag;
@@ -609,7 +615,7 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
)
).arg(titleblock_title).arg(tag);
}
-
+
return(titleblock_title);
}
@@ -620,11 +626,11 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
void QETTitleBlockTemplateEditor::readSettings()
{
QSettings settings;
-
+
// window size and position
QVariant geometry = settings.value("titleblocktemplateeditor/geometry");
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
-
+
// window state (toolbars, docks...)
QVariant state = settings.value("titleblocktemplateeditor/state");
if (state.isValid()) restoreState(state.toByteArray());
@@ -698,10 +704,10 @@ void QETTitleBlockTemplateEditor::updateEditorTitle()
"titleblock template editor: base window title"
)
);
-
+
// get the currently edited template (file)name
QString titleblock_title = currentlyEditedTitle();
-
+
// generate the final window title
QString title;
if (titleblock_title.isEmpty()) {
@@ -724,7 +730,7 @@ void QETTitleBlockTemplateEditor::updateEditorTitle()
void QETTitleBlockTemplateEditor::updateActions()
{
save_ -> setEnabled(!read_only_);
-
+
bool can_merge = true;
bool can_split = true;
int count = 0;
@@ -748,15 +754,15 @@ void QETTitleBlockTemplateEditor::updateActions()
bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &location) {
TitleBlockTemplatesCollection *collection = location.parentCollection();
if (!collection) return(false);
-
+
QDomDocument doc;
QDomElement elmt = doc.createElement("root");
tb_template_ -> saveToXmlElement(elmt);
elmt.setAttribute("name", location.name());
doc.appendChild(elmt);
-
+
collection -> setTemplateXmlDescription(location.name(), elmt);
-
+
opened_from_file_ = false;
location_ = location;
undo_stack_ -> setClean();
@@ -772,7 +778,7 @@ bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &locat
bool QETTitleBlockTemplateEditor::saveAs(const QString &filepath) {
bool saving = tb_template_ -> saveToXmlFile(filepath);
if (!saving) return(false);
-
+
opened_from_file_ = true;
filepath_ = filepath;
undo_stack_ -> setClean();
@@ -805,7 +811,7 @@ void QETTitleBlockTemplateEditor::openFromFile()
QString initial_dir = filepath_.isEmpty()
? QETApp::customTitleBlockTemplatesDir()
: QDir(filepath_).absolutePath();
-
+
// ask the user to choose a filepath
QString user_filepath = QFileDialog::getOpenFileName(
this,
@@ -819,8 +825,8 @@ void QETTitleBlockTemplateEditor::openFromFile()
" - %1 is the .titleblock extension"
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
);
-
-
+
+
if (!user_filepath.isEmpty()) QETApp::instance() -> openTitleBlockTemplate(user_filepath);
}
@@ -871,7 +877,7 @@ bool QETTitleBlockTemplateEditor::saveAsFile()
QString initial_dir = filepath_.isEmpty()
? QETApp::customTitleBlockTemplatesDir()
: QDir(filepath_).absolutePath();
-
+
// ask the user to choose a target file
QString filepath = QFileDialog::getSaveFileName(
this,
@@ -882,16 +888,16 @@ bool QETTitleBlockTemplateEditor::saveAsFile()
"filetypes allowed when saving a title block template file - %1 is the .titleblock extension"
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
);
-
+
// if no name was entered, return false
if (filepath.isEmpty()) return(false);
-
+
// if the name does not end with ".titleblock", add it
if (!filepath.endsWith(".titleblock", Qt::CaseInsensitive)) filepath += ".titleblock";
-
+
// attempts to save the file
bool saving = saveAs(filepath);
-
+
// retourne un booleen representatif de la reussite de l'enregistrement
return(saving);
}
@@ -932,18 +938,18 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLoc
}
QDialogButtonBox *buttons = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-
+
QVBoxLayout *dialog_layout = new QVBoxLayout();
dialog_layout -> addWidget(widget);
dialog_layout -> addWidget(buttons);
-
+
QDialog dialog;
dialog.setWindowTitle(title);
dialog.setLayout(dialog_layout);
-
+
connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
-
+
if (dialog.exec() == QDialog::Accepted) {
return(widget -> location());
}
@@ -978,7 +984,7 @@ void QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings(
void QETTitleBlockTemplateEditor::editTemplateInformation()
{
if (!tb_template_) return;
-
+
QDialog dialog_author(this);
dialog_author.setModal(true);
#ifdef Q_OS_MACOS
@@ -987,20 +993,20 @@ void QETTitleBlockTemplateEditor::editTemplateInformation()
dialog_author.setMinimumSize(400, 260);
dialog_author.setWindowTitle(tr("Éditer les informations complémentaires", "window title"));
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author);
-
+
// explanation label
QLabel *information_label = new QLabel(tr("Vous pouvez utiliser ce champ libre pour mentionner les auteurs du cartouche, sa licence, ou tout autre renseignement que vous jugerez utile."));
information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
information_label -> setWordWrap(true);
dialog_layout -> addWidget(information_label);
-
+
// add a QTextEdit to the dialog
QTextEdit *text_field = new QTextEdit();
text_field -> setAcceptRichText(false);
text_field -> setPlainText(tb_template_ -> information());
text_field -> setReadOnly(read_only_);
dialog_layout -> addWidget(text_field);
-
+
// add two buttons to the dialog
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(
read_only_
@@ -1012,7 +1018,7 @@ void QETTitleBlockTemplateEditor::editTemplateInformation()
&dialog_author, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()),
&dialog_author, SLOT(reject()));
-
+
// run the dialog
if (dialog_author.exec() == QDialog::Accepted && !read_only_) {
QString new_info = text_field -> toPlainText().remove(QChar(13)); // CR-less text
diff --git a/sources/titleblock/templatelocation.cpp b/sources/titleblock/templatelocation.cpp
index 95c40a717..3a20f7ef5 100644
--- a/sources/titleblock/templatelocation.cpp
+++ b/sources/titleblock/templatelocation.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -19,6 +19,8 @@
#include "templatescollection.h"
#include "qetapp.h"
+#include
+
// make this class usable with QVariant
int TitleBlockTemplateLocation::MetaTypeId = qRegisterMetaType("TitleBlockTemplateLocation");
@@ -97,10 +99,10 @@ bool TitleBlockTemplateLocation::isValid() const
*/
void TitleBlockTemplateLocation::fromString(const QString &loc_str) {
collection_ = QETApp::titleBlockTemplatesCollection(QUrl(loc_str).scheme());
-
- QRegExp name_from_url("^[^:]*:\\/\\/(.*)$");
- if (name_from_url.exactMatch(loc_str)) {
- name_ = name_from_url.capturedTexts().at(1);
+
+ QRegularExpression name_from_url("^[^:]*:\\/\\/(.*)$");
+ if (name_from_url==QRegularExpression(loc_str)) {
+ name_ = name_from_url.namedCaptureGroups().at(1);
} else {
name_ = QString();
}
diff --git a/sources/titleblock/templatescollection.cpp b/sources/titleblock/templatescollection.cpp
index 001b08945..cb2ed3d7a 100644
--- a/sources/titleblock/templatescollection.cpp
+++ b/sources/titleblock/templatescollection.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -20,6 +20,8 @@
#include "qetapp.h"
#include "qetproject.h"
+#include
+
/**
Constructor
@param parent Parent QObject
@@ -136,7 +138,7 @@ TitleBlockTemplatesProjectCollection::~TitleBlockTemplatesProjectCollection()
QString TitleBlockTemplatesProjectCollection::title() const
{
if (!title_.isEmpty()) return(title_);
-
+
// if the title attribute is empty, we generate a suitable one using the
// parent project
QString final_title;
@@ -204,12 +206,12 @@ TitleBlockTemplate *TitleBlockTemplatesProjectCollection::getTemplate(const QStr
if (titleblock_templates_.contains(template_name)) {
return(titleblock_templates_[template_name]);
}
-
+
// No? Do we even know of it?
if (!titleblock_templates_xml_.contains(template_name)) {
return(nullptr);
}
-
+
// Ok, we have its XML description, we have to generate a TitleBlockTemplate object
TitleBlockTemplate *titleblock_template = new TitleBlockTemplate(this);
if (titleblock_template -> loadFromXmlElement(titleblock_templates_xml_[template_name])) {
@@ -248,16 +250,16 @@ bool TitleBlockTemplatesProjectCollection::setTemplateXmlDescription(const QStri
if (xml_elmt.tagName() != "titleblocktemplate") {
return(false);
}
-
+
// we *require* a project (at least for the moment...)
if (!project_) return(false);
-
+
// we import the provided XML element in the project document
QDomElement import = xml_document_.importNode(xml_elmt, true).toElement();
-
+
// ensure the name stored in the XML description remains consistent with the provided template name
import.setAttribute("name", template_name);
-
+
// we either replace the previous description
if (titleblock_templates_xml_.contains(template_name)) {
QDomElement old_description = titleblock_templates_xml_[template_name];
@@ -266,12 +268,12 @@ bool TitleBlockTemplatesProjectCollection::setTemplateXmlDescription(const QStri
}
}
titleblock_templates_xml_.insert(template_name, import);
-
+
if (titleblock_templates_.contains(template_name)) {
titleblock_templates_[template_name] -> loadFromXmlElement(titleblock_templates_xml_[template_name]);
}
emit(changed(this, template_name));
-
+
return(true);
}
@@ -282,11 +284,11 @@ bool TitleBlockTemplatesProjectCollection::setTemplateXmlDescription(const QStri
*/
void TitleBlockTemplatesProjectCollection::removeTemplate(const QString &template_name) {
emit(aboutToRemove(this, template_name));
-
+
// remove the template itself
titleblock_templates_xml_.remove(template_name);
titleblock_templates_.remove(template_name);
-
+
// warn the rest of the world that the list of templates embedded within this project has changed
emit(changed(this, template_name));
}
@@ -339,10 +341,10 @@ void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_elemen
// each titleblock template must have a name
if (!e.hasAttribute("name")) continue;
QString titleblock_template_name = e.attribute("name");
-
+
// if several templates have the same name, we keep the first one encountered
if (titleblock_templates_xml_.contains(titleblock_template_name)) continue;
-
+
// we simply store the XML element describing the titleblock template,
// without any further analysis for the moment
titleblock_templates_xml_.insert(titleblock_template_name, e);
@@ -355,7 +357,7 @@ void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_elemen
void TitleBlockTemplatesProjectCollection::deleteUnusedTitleBlocKTemplates()
{
if (!project_) return;
-
+
foreach (QString template_name, templates()) {
if (!project_ -> usesTitleBlockTemplate(location(template_name))) {
removeTemplate(template_name);
@@ -408,7 +410,7 @@ QString TitleBlockTemplatesFilesCollection::path(const QString &template_name) c
QStringList TitleBlockTemplatesFilesCollection::templates()
{
QStringList templates_names;
- QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
+ QRegularExpression replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
foreach(QString name, dir_.entryList()) {
templates_names << name.replace(replace_regexp, "");
}
@@ -421,10 +423,10 @@ QStringList TitleBlockTemplatesFilesCollection::templates()
*/
TitleBlockTemplate *TitleBlockTemplatesFilesCollection::getTemplate(const QString &template_name) {
if (!templates().contains(template_name)) return(nullptr);
-
+
TitleBlockTemplate *tbtemplate = new TitleBlockTemplate();
QString tbt_file_path = path(template_name);
-
+
bool loading = tbtemplate -> loadFromXmlFile(tbt_file_path);
if (!loading) {
delete tbtemplate;
@@ -439,17 +441,17 @@ TitleBlockTemplate *TitleBlockTemplatesFilesCollection::getTemplate(const QStrin
*/
QDomElement TitleBlockTemplatesFilesCollection::getTemplateXmlDescription(const QString &template_name) {
QString xml_file_path = path(template_name);
-
+
QFileInfo xml_file_info(xml_file_path);
if (!xml_file_info.exists() || !xml_file_info.isReadable()) {
return(QDomElement());
}
-
+
QFile xml_file(xml_file_path);
if (!xml_file.open(QIODevice::ReadOnly)) {
return(QDomElement());
}
-
+
QDomDocument *xml_document = new QDomDocument();
bool xml_parsing = xml_document -> setContent(&xml_file);
if (!xml_parsing) {
@@ -466,16 +468,16 @@ QDomElement TitleBlockTemplatesFilesCollection::getTemplateXmlDescription(const
*/
bool TitleBlockTemplatesFilesCollection::setTemplateXmlDescription(const QString &template_name, const QDomElement &xml_element) {
if (template_name.isEmpty()) return(false);
-
+
// prevent the watcher from emitting signals while we open and write to file
blockSignals(true);
-
+
QDomDocument doc;
doc.appendChild(doc.importNode(xml_element, true));
-
+
bool writing = QET::writeXmlFile(doc, path(template_name));
if (!writing) return(false);
-
+
// emit a single signal for the change
blockSignals(false);
emit(changed(this, template_name));
@@ -489,9 +491,9 @@ void TitleBlockTemplatesFilesCollection::removeTemplate(const QString &template_
emit(aboutToRemove(this, template_name));
// prevent the watcher from emitting signals while we open and write to file
blockSignals(true);
-
+
dir_.remove(toFileName(template_name));
-
+
// emit a single signal for the removal
blockSignals(false);
emit(changed(this, template_name));
@@ -500,7 +502,7 @@ void TitleBlockTemplatesFilesCollection::removeTemplate(const QString &template_
/**
@param template_name Name of a template supposed to be contained within
this collection.
- @return
+ @return
*/
TitleBlockTemplateLocation TitleBlockTemplatesFilesCollection::location(const QString &template_name) {
return(TitleBlockTemplateLocation(template_name, this));
@@ -544,7 +546,7 @@ bool TitleBlockTemplatesFilesCollection::isReadOnly(const QString &template_name
@return the template name for \a file_name
*/
QString TitleBlockTemplatesFilesCollection::toTemplateName(const QString &file_name) {
- static QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
+ static QRegularExpression replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
QString template_name(file_name);
return(template_name.replace(replace_regexp, ""));
}
diff --git a/sources/titleblocktemplate.cpp b/sources/titleblocktemplate.cpp
index 479c57c52..acc44604b 100644
--- a/sources/titleblocktemplate.cpp
+++ b/sources/titleblocktemplate.cpp
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -23,6 +23,8 @@
// uncomment the line below to get more debug information
//#define TITLEBLOCK_TEMPLATE_DEBUG
+#include
+#include
/**
@brief TitleBlockTemplate::TitleBlockTemplate
Constructor
@@ -97,7 +99,7 @@ bool TitleBlockTemplate::loadFromXmlFile(const QString &filepath) {
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
qDebug() << Q_FUNC_INFO << filepath << "opened";
#endif
-
+
// parse its content as XML
QDomDocument xml_doc;
bool xml_parsing = xml_doc.setContent(&template_file);
@@ -124,11 +126,11 @@ bool TitleBlockTemplate::loadFromXmlElement(const QDomElement &xml_element) {
return(false);
}
name_ = xml_element.attribute("name");
-
+
loadInformation(xml_element);
loadLogos(xml_element, true);
loadGrid(xml_element);
-
+
return(true);
}
@@ -141,14 +143,14 @@ bool TitleBlockTemplate::loadFromXmlElement(const QDomElement &xml_element) {
*/
bool TitleBlockTemplate::saveToXmlFile(const QString &filepath) {
if (filepath.isEmpty()) return(false);
-
+
// generate the XML document
QDomDocument doc;
QDomElement e = doc.createElement("root");
bool saving = saveToXmlElement(e);
if (!saving) return(false);
doc.appendChild(e);
-
+
return(QET::writeXmlFile(doc, filepath));
}
@@ -163,7 +165,7 @@ bool TitleBlockTemplate::saveToXmlElement(QDomElement &xml_element) const
{
// we are supposed to have at least a name
if (name_.isEmpty()) return(false);
-
+
xml_element.setTagName("titleblocktemplate");
xml_element.setAttribute("name", name_);
saveInformation(xml_element);
@@ -195,7 +197,7 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
TitleBlockTemplate *copy = new TitleBlockTemplate();
copy -> name_ = name_;
copy -> information_ = information_;
-
+
// this does not really duplicates pixmaps,
// only the objects that hold a key to the implicitly shared pixmaps
foreach (QString logo_key, bitmap_logos_.keys()) {
@@ -209,20 +211,20 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
<< copy -> bitmap_logos_[logo_key] -> cacheKey();
#endif
}
-
+
// we have to create new QSvgRenderer objects from the data
// (no copy constructor)
foreach (QString logo_key, vector_logos_.keys()) {
copy -> vector_logos_[logo_key] =
new QSvgRenderer(data_logos_[logo_key]);
}
-
+
copy -> data_logos_ = data_logos_;
copy -> storage_logos_ = storage_logos_;
copy -> type_logos_ = type_logos_;
copy -> rows_heights_ = rows_heights_;
copy -> columns_width_ = columns_width_;
-
+
// copy cells basically
copy -> cells_ = cells_;
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
@@ -230,7 +232,7 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
copy -> cells_[i][j] = copy -> createCell(cells_[i][j]);
}
}
-
+
// ensure the copy has no spanner_cell attribute pointing to a cell
// from the original object
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
@@ -247,7 +249,7 @@ TitleBlockTemplate *TitleBlockTemplate::clone() const
}
}
}
-
+
return(copy);
}
@@ -278,15 +280,15 @@ bool TitleBlockTemplate::loadLogos(const QDomElement &xml_element, bool reset) {
if (reset) {
qDeleteAll(vector_logos_.begin(), vector_logos_.end());
vector_logos_.clear();
-
+
// Note:
// QPixmap are only a key to access the implicitly shared pixmap
bitmap_logos_.clear();
-
+
data_logos_.clear();
storage_logos_.clear();
}
-
+
// we look for //logos/logo elements
for (QDomNode n = xml_element.firstChild() ;
!n.isNull() ;
@@ -302,7 +304,7 @@ bool TitleBlockTemplate::loadLogos(const QDomElement &xml_element, bool reset) {
}
}
}
-
+
return(true);
}
@@ -321,7 +323,7 @@ bool TitleBlockTemplate::loadLogo(const QDomElement &xml_element) {
QString logo_name = xml_element.attribute("name");
QString logo_type = xml_element.attribute("type", "png");
QString logo_storage = xml_element.attribute("storage", "base64");
-
+
// Both QSvgRenderer and QPixmap read their data from a QByteArray, so
// we convert the available data to that format.
QByteArray logo_data;
@@ -342,7 +344,7 @@ bool TitleBlockTemplate::loadLogo(const QDomElement &xml_element) {
qDebug() << Q_FUNC_INFO << logo_name << logo_type << logo_storage;
#endif
addLogo(logo_name, &logo_data, logo_type, logo_storage);
-
+
return(true);
}
@@ -362,12 +364,12 @@ bool TitleBlockTemplate::loadGrid(const QDomElement &xml_element) {
break;
}
}
-
+
if (!grid_element.hasAttribute("rows")
|| !grid_element.hasAttribute("cols")) {
return(false);
}
-
+
parseRows(grid_element.attribute("rows"));
parseColumns(grid_element.attribute("cols"));
initCells();
@@ -386,7 +388,9 @@ bool TitleBlockTemplate::loadGrid(const QDomElement &xml_element) {
void TitleBlockTemplate::parseRows(const QString &rows_string) {
rows_heights_.clear();
// parse the rows attribute: we expect a serie of absolute heights
- QRegExp row_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
+ QRegularExpression row_size_format
+ ("^([0-9]+)(?:px)?$",
+ QRegularExpression::CaseInsensitiveOption);
bool conv_ok;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
@@ -398,10 +402,11 @@ void TitleBlockTemplate::parseRows(const QString &rows_string) {
rows_string.split(QChar(';'), Qt::SkipEmptyParts);
#endif
foreach (QString rows_description, rows_descriptions) {
- if (row_size_format.exactMatch(rows_description)) {
+ QRegularExpressionMatch match;
+ match = row_size_format.match(rows_description);
+ if (match.hasMatch()) {
int row_size =
- row_size_format.capturedTexts().at(1).toInt(
- &conv_ok);
+ match.captured(1).toInt(&conv_ok);
if (conv_ok)
rows_heights_ << row_size;
}
@@ -420,8 +425,12 @@ void TitleBlockTemplate::parseRows(const QString &rows_string) {
void TitleBlockTemplate::parseColumns(const QString &cols_string) {
columns_width_.clear();
// parse the cols attribute: we expect a serie of absolute or relative widths
- QRegExp abs_col_size_format("^([0-9]+)(?:px)?$", Qt::CaseInsensitive);
- QRegExp rel_col_size_format("^([rt])([0-9]+)%$", Qt::CaseInsensitive);
+ QRegularExpression abs_col_size_format,rel_col_size_format;
+ abs_col_size_format.setPattern("^([0-9]+)(?:px)?$");
+ abs_col_size_format.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
+ //QRegExp rel_col_size_format("^([rt])([0-9]+)%$", Qt::CaseInsensitive);
+ rel_col_size_format.setPattern("^([rt])([0-9]+)%$");
+ rel_col_size_format.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
bool conv_ok;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
@@ -433,18 +442,18 @@ void TitleBlockTemplate::parseColumns(const QString &cols_string) {
cols_string.split(QChar(';'), Qt::SkipEmptyParts);
#endif
foreach (QString cols_description, cols_descriptions) {
- if (abs_col_size_format.exactMatch(cols_description)) {
- int col_size = abs_col_size_format.capturedTexts().at(1).toInt(&conv_ok);
+ QRegularExpressionMatch match_abc,match_rel;
+ match_abc = abs_col_size_format.match(cols_description);
+ match_rel = rel_col_size_format.match(cols_description);
+ if (match_abc.hasMatch()) {
+ int col_size = match_abc.captured(1).toInt(&conv_ok);
if (conv_ok)
columns_width_ << TitleBlockDimension(
col_size,
QET::Absolute);
- } else if (rel_col_size_format.exactMatch(cols_description)) {
- int col_size =
- rel_col_size_format.capturedTexts().at(2).toInt(
- &conv_ok);
- QET::TitleBlockColumnLength col_type =
- rel_col_size_format.capturedTexts().at(1)
+ } else if (match_rel.hasMatch()) {
+ int col_size = match_rel.captured(2).toInt(&conv_ok);
+ QET::TitleBlockColumnLength col_type = match_rel.captured(1)
== "t"
? QET::RelativeToTotalLength
: QET::RelativeToRemainingLength;
@@ -508,7 +517,7 @@ void TitleBlockTemplate::saveInformation(QDomElement &xml_element) const
{
QDomNode information_text_node =
xml_element.ownerDocument().createTextNode(information());
-
+
QDomElement information_element =
xml_element.ownerDocument().createElement("information");
information_element.appendChild(information_text_node);
@@ -544,11 +553,11 @@ void TitleBlockTemplate::saveLogo(const QString &logo_name,
QDomElement &xml_element) const
{
if (!type_logos_.contains(logo_name)) return;
-
+
xml_element.setAttribute("name", logo_name);
xml_element.setAttribute("type", type_logos_[logo_name]);
xml_element.setAttribute("storage", storage_logos_[logo_name]);
-
+
if (storage_logos_[logo_name] == "xml"
&& type_logos_[logo_name] == "svg") {
QDomDocument svg_logo;
@@ -575,7 +584,7 @@ void TitleBlockTemplate::saveGrid(QDomElement &xml_element) const
{
QDomElement grid_element =
xml_element.ownerDocument().createElement("grid");
-
+
QString rows_attr, cols_attr;
foreach(int row_height, rows_heights_)
rows_attr += QString("%1;").arg(row_height);
@@ -583,9 +592,9 @@ void TitleBlockTemplate::saveGrid(QDomElement &xml_element) const
cols_attr += col_width.toShortString();
grid_element.setAttribute("rows", rows_attr);
grid_element.setAttribute("cols", cols_attr);
-
+
saveCells(grid_element);
-
+
xml_element.appendChild(grid_element);
}
@@ -625,12 +634,12 @@ void TitleBlockTemplate::saveCell(TitleBlockCell *cell,
if (cell -> spanner_cell) return;
if (!save_empty && cell -> cell_type == TitleBlockCell::EmptyCell)
return;
-
-
+
+
QDomElement cell_elmt =
xml_element.ownerDocument().createElement("cell");
xml_element.appendChild(cell_elmt);
-
+
// save information dependent from this template
cell_elmt.setAttribute("row", cell -> num_row);
cell_elmt.setAttribute("col", cell -> num_col);
@@ -638,7 +647,7 @@ void TitleBlockTemplate::saveCell(TitleBlockCell *cell,
cell -> row_span);
if (cell -> col_span) cell_elmt.setAttribute("colspan",
cell -> col_span);
-
+
// save other information
cell -> saveContentToXml(cell_elmt);
}
@@ -659,15 +668,15 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
TitleBlockCell **titleblock_cell_ptr) {
int col_count = columns_width_.count(),
row_count = rows_heights_.count();
-
+
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
qDebug() << Q_FUNC_INFO << "begin" << row_count << col_count;
#endif
-
+
int row_num, col_num, row_span, col_span;
row_num = col_num = -1;
row_span = col_span = 0;
-
+
// parse the row and col attributes
if (!QET::attributeIsAnInteger(xml_element, "row", &row_num)
|| row_num < 0
@@ -679,7 +688,7 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
|| col_num >= col_count) {
return(false);
}
-
+
// check whether the target cell can be used or not
#ifdef TITLEBLOCK_TEMPLATE_DEBUG
qDebug() << Q_FUNC_INFO << "cell access" << col_num << row_num;
@@ -692,20 +701,20 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
// ensure the num_row and num_col attributes are alright
cell_ptr -> num_row = row_num;
cell_ptr -> num_col = col_num;
-
+
// parse the rowspan and colspan attributes
if (QET::attributeIsAnInteger(xml_element, "rowspan", &row_span)
&& row_span > 0) {
cell_ptr -> row_span = row_span;
}
-
+
if (QET::attributeIsAnInteger(xml_element, "colspan", &col_span)
&& col_span > 0) {
cell_ptr -> col_span = col_span;
}
// these attributes are stored "as is" -- whether they can be applied
// directly or must be restricted will be checked later
-
+
if (titleblock_cell_ptr) *titleblock_cell_ptr = cell_ptr;
return(true);
}
@@ -719,7 +728,7 @@ bool TitleBlockTemplate::checkCell(const QDomElement &xml_element,
void TitleBlockTemplate::initCells()
{
if (columns_width_.count() < 1 || rows_heights_.count() < 1) return;
-
+
cells_.clear();
qDeleteAll(registered_cells_);
registered_cells_.clear();
@@ -838,12 +847,12 @@ int TitleBlockTemplate::rowsCount() const
QList TitleBlockTemplate::columnsWidth(int total_width) const
{
if (total_width < 0) return(QList());
-
+
// we first iter to determine the absolute and total-width-related widths
QVector final_widths(columns_width_.count());
int abs_widths_sum = 0, rel_widths_sum = 0;
QList relative_columns;
-
+
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
TitleBlockDimension icd = columns_width_.at(i);
if (icd.type == QET::Absolute) {
@@ -856,10 +865,10 @@ QList TitleBlockTemplate::columnsWidth(int total_width) const
final_widths[i] = abs_value;
}
}
-
+
// we can now deduce the remaining width
int remaining_width = total_width - abs_widths_sum;
-
+
// we do a second iteration to build the final widths list
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
TitleBlockDimension icd = columns_width_.at(i);
@@ -870,14 +879,14 @@ QList TitleBlockTemplate::columnsWidth(int total_width) const
rel_widths_sum += final_widths[i];
}
}
-
+
// Have we computed widths from percentage for relative columns?
if (relative_columns.count()) {
// Due to the rounding process,
// we may get a slight difference between the
// sum of the columns widths and the total width.
int difference = total_width - abs_widths_sum - rel_widths_sum;
-
+
if (difference) {
// We consider we should not attempt to compensate
// this difference if it is under
@@ -886,7 +895,7 @@ QList TitleBlockTemplate::columnsWidth(int total_width) const
// columns can "bring" up to 0.5px of difference).
qreal max_acceptable_difference =
relative_columns.count() * 0.5;
-
+
int share = difference > 0 ? 1 : -1;
if (qAbs(difference) <= max_acceptable_difference) {
while (difference) {
@@ -914,32 +923,32 @@ QList TitleBlockTemplate::rowsHeights() const
/**
@brief TitleBlockTemplate::columnTypeCount
@param type : a column type
- @return the count of \a type columns
+ @return the count of \a type columns
*/
int TitleBlockTemplate::columnTypeCount(QET::TitleBlockColumnLength type) {
int count = 0;
-
+
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
if (columns_width_.at(i).type == type) ++ count;
}
-
+
return(count);
}
/**
@brief TitleBlockTemplate::columnTypeTotal
@param type : a column type
- @return the sum of values attached to \a type columns
+ @return the sum of values attached to \a type columns
*/
int TitleBlockTemplate::columnTypeTotal(QET::TitleBlockColumnLength type) {
int total = 0;
-
+
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
if (columns_width_.at(i).type == type) {
total += columns_width_.at(i).value;
}
}
-
+
return(total);
}
@@ -951,7 +960,7 @@ int TitleBlockTemplate::minimumWidth()
// Abbreviations: ABS: absolute, RTT: relative to total, RTR:
// relative to remaining,
// TOT: total diagram/TBT width (variable).
-
+
// Minimum size may be enforced by ABS and RTT widths:
// TOT >= ((sum(REL)/100)*TOT)+sum(ABS)
// => (1 - (sum(REL)/100))TOT >= sum(ABS)
@@ -1050,7 +1059,7 @@ bool TitleBlockTemplate::insertRow(int dimension,
const QList &row,
int i) {
int index = (i == -1) ? rows_heights_.count() : i;
-
+
for (int j = 0 ; j < columns_width_.count() ; ++ j) {
cells_[j].insert(index, row[j]);
}
@@ -1166,7 +1175,7 @@ TitleBlockCell *TitleBlockTemplate::cell(int row, int col) const
{
if (row >= rows_heights_.count()) return(nullptr);
if (col >= columns_width_.count()) return(nullptr);
-
+
return(cells_[col][row]);
}
@@ -1198,7 +1207,7 @@ QSet TitleBlockTemplate::spannedCells(
? given_cell -> col_span
: given_cell -> applied_col_span;
if (!final_row_span && !final_col_span) return(set);
-
+
for (int i = given_cell -> num_col ;
i <= given_cell -> num_col + final_col_span ;
++ i) {
@@ -1269,7 +1278,7 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
// we are replacing the logo
removeLogo(logo_name);
}
-
+
// we can now create our image object from the byte array
if (logo_type == "svg") {
// SVG format is handled by the QSvgRenderer class
@@ -1278,7 +1287,7 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
return(false);
}
vector_logos_.insert(logo_name, svg);
-
+
// we also memorize the way to store them in the final XML output
QString final_logo_storage = logo_storage;
if (logo_storage != "xml" && logo_storage != "base64") {
@@ -1286,7 +1295,7 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
}
storage_logos_.insert(logo_name, logo_storage);
} else {
-
+
// bitmap formats are handled by the QPixmap class
QPixmap logo_pixmap;
logo_pixmap.loadFromData(*logo_data);
@@ -1294,15 +1303,15 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name,
return(false);
}
bitmap_logos_.insert(logo_name, logo_pixmap);
-
+
// bitmap logos can only be stored using a base64 encoding
storage_logos_.insert(logo_name, "base64");
}
-
+
// we systematically store the raw data
data_logos_.insert(logo_name, *logo_data);
type_logos_.insert(logo_name, logo_type);
-
+
return(true);
}
@@ -1320,15 +1329,15 @@ bool TitleBlockTemplate::addLogoFromFile(const QString &filepath,
QFileInfo filepath_info(filepath);
QString filename = name.isEmpty() ? filepath_info.fileName() : name;
QString filetype = filepath_info.suffix();
-
+
// we read the provided logo
QFile logo_file(filepath);
if (!logo_file.open(QIODevice::ReadOnly)) return(false);
QByteArray file_content = logo_file.readAll();
-
+
// first, we try to add it as an SVG image
if (addLogo(filename, &file_content, "svg", "xml")) return(true);
-
+
// we then try to add it as a bitmap image
return addLogo(filename,
&file_content,
@@ -1349,12 +1358,12 @@ bool TitleBlockTemplate::saveLogoToFile(const QString &logo_name,
if (!data_logos_.contains(logo_name)) {
return(false);
}
-
+
QFile target_file(filepath);
if (!target_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
return(false);
}
-
+
target_file.write(data_logos_[logo_name]);
target_file.close();
return(true);
@@ -1395,7 +1404,7 @@ bool TitleBlockTemplate::renameLogo(const QString &logo_name,
|| data_logos_.contains(new_name)) {
return(false);
}
-
+
/// TODO check existing cells using this logo.
if (vector_logos_.contains(logo_name)) {
vector_logos_.insert(new_name, vector_logos_.take(logo_name));
@@ -1493,16 +1502,16 @@ void TitleBlockTemplate::render(QPainter &painter,
{
QList widths = columnsWidth(titleblock_width);
int titleblock_height = height();
-
+
painter.save();
//Setup the QPainter
QPen pen(Qt::black);
pen.setCosmetic(true);
painter.setPen(pen);
-
+
// draw the titleblock border
painter.drawRect(QRect(0, 0, titleblock_width, titleblock_height));
-
+
// run through each individual cell
for (int j = 0 ; j < rows_heights_.count() ; ++ j) {
for (int i = 0 ; i < columns_width_.count() ; ++ i) {
@@ -1510,13 +1519,13 @@ void TitleBlockTemplate::render(QPainter &painter,
|| cells_[i][j] -> cell_type
== TitleBlockCell::EmptyCell)
continue;
-
+
// calculate the border rect of the current cell
int x = lengthRange(0, cells_[i][j] -> num_col, widths);
int y = lengthRange(0,
cells_[i][j] -> num_row,
rows_heights_);
-
+
int row_span = 0, col_span = 0;
if (cells_[i][j] -> span_state
!= TitleBlockCell::Disabled) {
@@ -1530,7 +1539,7 @@ void TitleBlockTemplate::render(QPainter &painter,
cells_[i][j] -> num_row + 1 + row_span,
rows_heights_);
QRect cell_rect(x, y, w, h);
-
+
renderCell(painter, *cells_[i][j],
diagram_context,
cell_rect);
@@ -1647,7 +1656,7 @@ void TitleBlockTemplate::renderCell(QPainter &painter,
pen.setColor(Qt::black);
painter.setPen(pen);
painter.drawRect(cell_rect);
-
+
painter.save();
// render the inner content of the current cell
if (cell.type() == TitleBlockCell::LogoCell) {
@@ -1672,7 +1681,7 @@ void TitleBlockTemplate::renderCell(QPainter &painter,
renderTextCell(painter, final_text, cell, cell_rect);
}
painter.restore();
-
+
// draw again the border rect of the current cell, without the brush this time
painter.setBrush(Qt::NoBrush);
painter.drawRect(cell_rect);
@@ -1695,9 +1704,9 @@ QString TitleBlockTemplate::finalTextForCell(
{
QString cell_text = cell.value.name();
QString cell_label = cell.label.name();
-
+
cell_text = interpreteVariables(cell_text, diagram_context);
-
+
if (cell.display_label && !cell.label.isEmpty()) {
cell_label = interpreteVariables(cell_label, diagram_context);
cell_text = QString(tr(" %1 : %2", "titleblock content - please let the blank space at the beginning")).arg(cell_label).arg(cell_text);
@@ -1749,7 +1758,7 @@ QStringList TitleBlockTemplate::listOfVariables()
#pragma message("@TODO not works on all cases...")
// TODO: not works on all cases...
list << cells_[i][j] -> value.name().replace("%","");
- }
+ }
}
qDebug() << list;
return list;
@@ -1778,25 +1787,25 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
if (text.isEmpty()) return;
QFont text_font = TitleBlockTemplate::fontForCell(cell);
painter.setFont(text_font);
-
+
if (cell.hadjust) {
QFontMetricsF font_metrics(text_font);
QRectF font_rect = font_metrics.boundingRect(
QRect(-10000, -10000, 10000, 10000),
cell.alignment,
text);
-
+
if (font_rect.width() > cell_rect.width()) {
qreal ratio = qreal(cell_rect.width())
/ qreal(font_rect.width());
painter.save();
-
+
painter.translate(cell_rect.topLeft());
qreal vertical_adjustment =
cell_rect.height() * (1 - ratio) / 2.0;
painter.translate(0.0, vertical_adjustment);
painter.scale(ratio, ratio);
-
+
QRectF new_world_cell_rect(cell_rect);
new_world_cell_rect.moveTo(0, 0.0);
new_world_cell_rect.setWidth(new_world_cell_rect.width()
@@ -1804,12 +1813,12 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
painter.drawText(new_world_cell_rect,
cell.alignment,
text);
-
+
painter.restore();
return;
}
}
-
+
// Still here? Let's draw the text normally
painter.drawText(cell_rect, cell.alignment, text);
}
@@ -1825,14 +1834,15 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
@param h
@param color
*/
-void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
- const QString &text,
- const TitleBlockCell &cell,
- qreal x,
- qreal y,
- qreal w,
- qreal h,
- int color) const
+void TitleBlockTemplate::renderTextCellDxf(
+ QString &file_path,
+ const QString &text,
+ const TitleBlockCell &cell,
+ qreal x,
+ qreal y,
+ qreal w,
+ qreal h,
+ int color) const
{
if (text.isEmpty()) return;
QFont text_font = TitleBlockTemplate::fontForCell(cell);
@@ -1841,61 +1851,73 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
textHeight = text_font.pixelSize();
qreal x2 = x + w;
- qreal y1 = y;
+ qreal y1 = y;
int vAlign = 0;
int hAlign = 0;
- x2 = x; // default
+ x2 = x; // default
- if ( cell.alignment & Qt::AlignTop ) {
- vAlign = 3;
- y1 = y + h - (textHeight*Createdxf::yScale / 8);
- } else if ( cell.alignment & Qt::AlignVCenter ) {
- vAlign = 2;
- y1 = y + h/2;
- } else if ( cell.alignment & Qt::AlignBottom ) {
- y1 = y + (textHeight*Createdxf::yScale / 8);
- }
+ if ( cell.alignment & Qt::AlignTop )
+ {
+ vAlign = 3;
+ y1 = y + h - (textHeight*Createdxf::yScale / 8);
+ }
+ else if ( cell.alignment & Qt::AlignVCenter )
+ {
+ vAlign = 2;
+ y1 = y + h/2;
+ }
+ else if ( cell.alignment & Qt::AlignBottom )
+ {
+ y1 = y + (textHeight*Createdxf::yScale / 8);
+ }
- if ( cell.alignment & Qt::AlignRight ) {
+ if ( cell.alignment & Qt::AlignRight )
+ {
hAlign = 2;
- x2 = x + w;
- } else if ( cell.alignment & Qt::AlignHCenter ) {
+ x2 = x + w;
+ }
+ else if ( cell.alignment & Qt::AlignHCenter )
+ {
hAlign = 1;
x2 = x + w/2;
- } else if (cell.alignment & Qt::AlignJustify ) {
+ }
+ else if (cell.alignment & Qt::AlignJustify )
+ {
hAlign = 5;
- vAlign = 0;
- x2 = x + w;
- y1 = y + textHeight*Createdxf::yScale / 8;
+ vAlign = 0;
+ x2 = x + w;
+ y1 = y + textHeight*Createdxf::yScale / 8;
}
//painter.setFont(text_font);
- qreal ratio = 1.0;
+ qreal ratio = 1.0;
- if (cell.hadjust) {
- // Scale font width to fit string in cell width w
- // As DXF font aspect ratio is implementation dependent we add a fudge-factor based on tests with AutoCAD
- int len = text.length() * textHeight * Createdxf::xScale * 1.2;
+ if (cell.hadjust)
+ {
+ // Scale font width to fit string in cell width w
+ // As DXF font aspect ratio is implementation dependent we add a fudge-factor based on tests with AutoCAD
+ int len = text.length() * textHeight * Createdxf::xScale * 1.2;
- if(len > w)
- ratio = (w/len);
+ if(len > w)
+ ratio = (w/len);
}
- // x offset value below currently set heuristically based on appearance...
- Createdxf::drawTextAligned(file_path,
- text,
- x - 2*Createdxf::xScale,
- y1,
- textHeight*Createdxf::yScale,
- 0,
- 0,
- hAlign,
- vAlign,
- x2,
- ratio,
- color);
+ // x offset value below currently set heuristically based on appearance...
+ Createdxf::drawTextAligned(
+ file_path,
+ text,
+ x - 2*Createdxf::xScale,
+ y1,
+ textHeight*Createdxf::yScale,
+ 0,
+ 0,
+ hAlign,
+ vAlign,
+ x2,
+ ratio,
+ color);
}
/**
@@ -1965,11 +1987,11 @@ void TitleBlockTemplate::applyCellSpans()
*/
bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
if (!cell) return(false);
-
+
cell -> span_state = TitleBlockCell::Enabled;
cell -> applied_row_span = cell -> row_span;
cell -> applied_col_span = cell -> col_span;
-
+
// ensure the cell can span as far as required
if (cell -> num_col + cell -> col_span >= columnsCount()) {
cell -> applied_col_span = columnsCount() - 1 - cell -> num_col;
@@ -1979,7 +2001,7 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
cell -> applied_row_span = rowsCount() - 1 - cell -> num_row;
cell -> span_state = TitleBlockCell::Restricted;
}
-
+
// ensure cells that will be spanned are either empty or free
for (int i = cell -> num_col ;
i <= cell -> num_col + cell -> applied_col_span ;
@@ -2006,7 +2028,7 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
}
}
}
-
+
return(true);
}
@@ -2019,10 +2041,11 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
@param cell :
Potentially spanning cell
*/
-void TitleBlockTemplate::applyCellSpan(TitleBlockCell *cell) {
+void TitleBlockTemplate::applyCellSpan(TitleBlockCell *cell)
+{
if (!cell || (!cell -> row_span && !cell -> col_span)) return;
if (cell -> span_state == TitleBlockCell::Disabled) return;
-
+
// goes through every spanned cell
for (int i = cell -> num_col ;
i <= cell -> num_col + cell -> applied_col_span ;
@@ -2093,7 +2116,7 @@ int TitleBlockTemplate::lengthRange(
#endif
return(0);
}
-
+
int length = 0;
for (int i = start ; i < end ; ++i) {
length += lengths_list[i];
diff --git a/sources/ui/diagramcontextwidget.cpp b/sources/ui/diagramcontextwidget.cpp
index 88bf8621a..222f5b514 100644
--- a/sources/ui/diagramcontextwidget.cpp
+++ b/sources/ui/diagramcontextwidget.cpp
@@ -1,23 +1,25 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#include "diagramcontextwidget.h"
#include "ui_diagramcontextwidget.h"
+#include
+
DiagramContextWidget::DiagramContextWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::DiagramContextWidget)
@@ -38,7 +40,7 @@ DiagramContextWidget::~DiagramContextWidget()
DiagramContext DiagramContextWidget::context() const
{
DiagramContext context;
-
+
for (int i = 0 ; i < ui->m_table-> rowCount() ; ++ i)
{
QTableWidgetItem *qtwi_name = ui->m_table-> item(i, 0);
@@ -46,16 +48,16 @@ DiagramContext DiagramContextWidget::context() const
if (!qtwi_name || !qtwi_value) {
continue;
}
-
+
QString key = qtwi_name -> text();
if (key.isEmpty()) {
continue;
}
-
+
QString value = qtwi_value -> text();
context.addValue(key, value);
}
-
+
return(context);
}
@@ -67,7 +69,7 @@ DiagramContext DiagramContextWidget::context() const
void DiagramContextWidget::setContext (const DiagramContext &context)
{
clear();
-
+
int i = 0;
for (QString key : context.keys(DiagramContext::Alphabetical))
{
@@ -75,7 +77,7 @@ void DiagramContextWidget::setContext (const DiagramContext &context)
ui->m_table->setItem(i, 1, new QTableWidgetItem(context[key].toString()));
++ i;
}
-
+
checkTableRows();
}
@@ -93,7 +95,7 @@ int DiagramContextWidget::nameLessRowsCount() const
++ name_less_rows_count;
}
}
-
+
return(name_less_rows_count);
}
@@ -107,7 +109,7 @@ void DiagramContextWidget::clear()
for (int i = 1 ; i < ui->m_table->rowCount() ; ++ i) {
ui->m_table->removeRow(i);
}
-
+
refreshFormatLabel();
}
@@ -118,10 +120,10 @@ void DiagramContextWidget::clear()
*/
int DiagramContextWidget::highlightNonAcceptableKeys()
{
- static QRegExp re(DiagramContext::validKeyRegExp());
-
+ static QRegularExpression re(DiagramContext::validKeyRegExp());
+
QBrush fg_brush = ui->m_table->palette().brush(QPalette::WindowText);
-
+
int invalid_keys = 0;
for (int i = 0 ; i < ui->m_table->rowCount() ; ++ i)
{
@@ -129,11 +131,11 @@ int DiagramContextWidget::highlightNonAcceptableKeys()
if (!qtwi_name) {
continue;
}
-
+
bool highlight = false;
if (!qtwi_name -> text().isEmpty())
{
- if (!re.exactMatch(qtwi_name -> text()))
+ if (re!=QRegularExpression(qtwi_name -> text()))
{
highlight = true;
++ invalid_keys;
@@ -141,7 +143,7 @@ int DiagramContextWidget::highlightNonAcceptableKeys()
}
qtwi_name -> setForeground(highlight ? Qt::red : fg_brush);
}
-
+
return(invalid_keys);
}
@@ -156,7 +158,7 @@ void DiagramContextWidget::refreshFormatLabel()
"Les noms ne peuvent contenir que des lettres minuscules, des "
"chiffres et des tirets."
);
-
+
if (highlightNonAcceptableKeys()) {
format_text = QString("%1").arg(format_text);
}
diff --git a/sources/ui/dynamicelementtextmodel.h b/sources/ui/dynamicelementtextmodel.h
index 4684c28fd..bceb1eff7 100644
--- a/sources/ui/dynamicelementtextmodel.h
+++ b/sources/ui/dynamicelementtextmodel.h
@@ -19,6 +19,8 @@
#define DYNAMICELEMENTTEXTMODEL_H
#include
+#include
+
#include
#include "dynamicelementtextitem.h"
@@ -35,7 +37,7 @@ class Element;
class DynamicElementTextModel : public QStandardItemModel
{
Q_OBJECT
-
+
public:
enum ValueType {
textFrom =1,
@@ -58,10 +60,10 @@ class DynamicElementTextModel : public QStandardItemModel
grpHoldBottom,
grpFrame
};
-
+
DynamicElementTextModel(Element *element, QObject *parent = nullptr);
~DynamicElementTextModel() override;
-
+
bool indexIsInGroup(const QModelIndex &index) const;
DynamicElementTextItem *textFromIndex(const QModelIndex &index) const;
DynamicElementTextItem *textFromItem(QStandardItem *item) const;
@@ -72,13 +74,13 @@ class DynamicElementTextModel : public QStandardItemModel
QUndoCommand *undoForEditedGroup(
ElementTextItemGroup *group,
QUndoCommand *parent_undo = nullptr) const;
-
+
ElementTextItemGroup *groupFromIndex(const QModelIndex &index) const;
ElementTextItemGroup *groupFromItem(QStandardItem *item) const;
QModelIndex indexFromGroup(ElementTextItemGroup *group) const;
bool indexIsText(const QModelIndex &index) const;
bool indexIsGroup(const QModelIndex &index) const;
-
+
bool canDropMimeData(
const QMimeData *data,
Qt::DropAction action,
@@ -93,10 +95,10 @@ class DynamicElementTextModel : public QStandardItemModel
const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
QStringList mimeTypes() const override;
-
+
signals:
void dataChanged();
-
+
private:
QList itemsForText(DynamicElementTextItem *deti);
void addText(DynamicElementTextItem *deti);
@@ -119,7 +121,7 @@ class DynamicElementTextModel : public QStandardItemModel
DynamicElementTextModel::ValueType type);
void updateDataFromGroup(ElementTextItemGroup *group,
DynamicElementTextModel::ValueType type);
-
+
private:
QPointer m_element;
QHash m_texts_list;
@@ -134,10 +136,10 @@ class DynamicElementTextModel : public QStandardItemModel
class DynamicTextItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
-
+
public:
DynamicTextItemDelegate(QObject *parent = Q_NULLPTR);
-
+
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
@@ -146,10 +148,10 @@ class DynamicTextItemDelegate : public QStyledItemDelegate
QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const override;
-
+
protected:
bool eventFilter(QObject *object, QEvent *event) override;
-
+
private:
QStringList availableInfo(DynamicElementTextItem *deti) const;
};
diff --git a/sources/ui/linksingleelementwidget.h b/sources/ui/linksingleelementwidget.h
index 19b389fb3..cd436322e 100644
--- a/sources/ui/linksingleelementwidget.h
+++ b/sources/ui/linksingleelementwidget.h
@@ -18,6 +18,8 @@
#ifndef LINKSINGLEELEMENTWIDGET_H
#define LINKSINGLEELEMENTWIDGET_H
+#include
+
#include "element.h"
#include "abstractelementpropertieseditorwidget.h"
@@ -73,30 +75,30 @@ class LinkSingleElementWidget : public AbstractElementPropertiesEditorWidget
void hideButtons();
void showButtons();
void headerCustomContextMenuRequested(const QPoint &pos);
-
+
void on_m_unlink_pb_clicked();
void on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_m_tree_widget_customContextMenuRequested(const QPoint &pos);
void on_m_show_linked_pb_clicked();
void on_m_show_this_pb_clicked();
-
+
void on_m_search_field_textEdited(const QString &arg1);
-
+
private:
Ui::LinkSingleElementWidget *ui;
bool m_unlink = false;
Element::kind m_filter;
-
+
QHash m_qtwi_elmt_hash;
QHash m_qtwi_strl_hash;
-
+
QTreeWidgetItem *m_qtwi_at_context_menu = nullptr,
*m_pending_qtwi = nullptr;
-
+
Element *m_showed_element = nullptr,
*m_element_to_link = nullptr;
-
+
QMenu *m_context_menu;
QAction *m_link_action,
*m_show_qtwi,
diff --git a/sources/ui/masterpropertieswidget.h b/sources/ui/masterpropertieswidget.h
index 155019123..a75ed1311 100644
--- a/sources/ui/masterpropertieswidget.h
+++ b/sources/ui/masterpropertieswidget.h
@@ -20,6 +20,7 @@
#include
#include
+
#include "abstractelementpropertieseditorwidget.h"
class Element;
diff --git a/sources/ui/multipastedialog.cpp b/sources/ui/multipastedialog.cpp
index 9f66a0519..ea0bf2753 100644
--- a/sources/ui/multipastedialog.cpp
+++ b/sources/ui/multipastedialog.cpp
@@ -15,13 +15,16 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
+
+#include
+#include
+
#include "multipastedialog.h"
#include "ui_multipastedialog.h"
#include "diagram.h"
#include "diagramcommands.h"
#include "element.h"
#include "conductorautonumerotation.h"
-#include
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(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
connect(ui->m_y_sb, static_cast(&QSpinBox::valueChanged), this, &MultiPasteDialog::updatePreview);
connect(ui->m_copy_count, static_cast(&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 ; im_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 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 pair = elmt->AlignedFreeTerminals().takeFirst();
-
+
Conductor *conductor = new Conductor(pair.first, pair.second);
m_diagram->undoStack().push(new AddItemCommand(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 autonums = m_diagram->project()->elementAutoNum();
QHashIterator 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 numerated;
//Start with the element at top
@@ -184,7 +187,7 @@ void MultiPasteDialog::on_m_button_box_accepted()
{
QHash autonums = m_diagram->project()->conductorAutoNum();
QHashIterator 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);
diff --git a/sources/ui/potentialselectordialog.cpp b/sources/ui/potentialselectordialog.cpp
index daa49b227..bfbededa4 100644
--- a/sources/ui/potentialselectordialog.cpp
+++ b/sources/ui/potentialselectordialog.cpp
@@ -15,11 +15,14 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
+
+#include
+#include
+
#include "potentialselectordialog.h"
#include "ui_potentialselectordialog.h"
#include "conductor.h"
#include "terminal.h"
-#include
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "diagram.h"
#include "element.h"
@@ -191,14 +194,14 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QList H;
for (ConductorProperties cp : list)
{
@@ -213,7 +216,7 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QListisChecked()) {
return H.value(b);
}
}
-
+
return ConductorProperties();
}
@@ -290,7 +293,7 @@ void PotentialSelectorDialog::buildWidget()
QString text1(tr("%n conducteurs composent le potentiel suivant :",
"",
m_potential_selector->m_conductor_number_1));
-
+
ConductorProperties cp1;
if(!m_potential_selector->m_properties_list_1.isEmpty())
cp1 = m_potential_selector->m_properties_list_1.first();;
@@ -308,14 +311,14 @@ void PotentialSelectorDialog::buildWidget()
if(!cp1.m_wire_section.isEmpty())
text1.append(tr("\nSection du conducteur : %1")
.arg(cp1.m_wire_section));
-
+
QString text2(tr("%n conducteurs composent le potentiel suivant :",
"",
m_potential_selector->m_conductor_number_2));
ConductorProperties cp2;
if(!m_potential_selector->m_properties_list_2.isEmpty())
cp2 = m_potential_selector->m_properties_list_2.first();
-
+
if(!cp2.text.isEmpty())
text2.append(tr("\nNuméro : %1").arg(cp2.text));
if(!cp2.m_function.isEmpty())
@@ -329,7 +332,7 @@ void PotentialSelectorDialog::buildWidget()
if(!cp2.m_wire_section.isEmpty())
text2.append(tr("\nSection du conducteur : %1")
.arg(cp2.m_wire_section));
-
+
QRadioButton *rb1 = new QRadioButton(text1, this);
QRadioButton *rb2 = new QRadioButton(text2, this);
@@ -429,7 +432,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
new_value,
undo);
}
-
+
//Check if formula of the new potential
// have incompatible variable with folio report
QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
@@ -445,7 +448,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
<< "%F"
<< "%M"
<< "%LM";
-
+
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"
"Les variables suivantes sont incompatibles :\n"
@@ -455,7 +458,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
fag.setText(text);
fag.setFormula(cp.m_formula);
fag.exec();
-
+
QString new_formula = fag.formula();
QSet c_list = m_report->conductors().first()->relatedPotentialConductors();
c_list.insert(m_report->conductors().first());
@@ -471,7 +474,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted()
new_value,
undo);
}
-
+
break;
}
}
diff --git a/sources/ui/shapegraphicsitempropertieswidget.cpp b/sources/ui/shapegraphicsitempropertieswidget.cpp
index 6a0519f33..97c07e465 100644
--- a/sources/ui/shapegraphicsitempropertieswidget.cpp
+++ b/sources/ui/shapegraphicsitempropertieswidget.cpp
@@ -15,6 +15,9 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
+
+#include
+
#include "shapegraphicsitempropertieswidget.h"
#include "ui_shapegraphicsitempropertieswidget.h"
#include "qetshapeitem.h"
diff --git a/sources/ui/xrefpropertieswidget.cpp b/sources/ui/xrefpropertieswidget.cpp
index c14b75a1c..b5f9ff002 100644
--- a/sources/ui/xrefpropertieswidget.cpp
+++ b/sources/ui/xrefpropertieswidget.cpp
@@ -15,12 +15,14 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
-#include "xrefpropertieswidget.h"
#include
+#include
+#include
+
+#include "xrefpropertieswidget.h"
#include "ui_xrefpropertieswidget.h"
#include "qdebug.h"
-#include
/**
@brief XRefPropertiesWidget::XRefPropertiesWidget
diff --git a/sources/ui/xrefpropertieswidget.h b/sources/ui/xrefpropertieswidget.h
index 73d33a9e9..bd7471cd4 100644
--- a/sources/ui/xrefpropertieswidget.h
+++ b/sources/ui/xrefpropertieswidget.h
@@ -19,6 +19,8 @@
#define XREFPROPERTIESWIDGET_H
#include
+#include
+
#include "properties/xrefproperties.h"
namespace Ui {
diff --git a/sources/undocommand/addelementtextcommand.h b/sources/undocommand/addelementtextcommand.h
index fc73f1d9b..5697db885 100644
--- a/sources/undocommand/addelementtextcommand.h
+++ b/sources/undocommand/addelementtextcommand.h
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -21,6 +21,7 @@
#include
#include
#include
+#include
class Element;
class DynamicElementTextItem;
@@ -37,10 +38,10 @@ class AddElementTextCommand : public QUndoCommand
DynamicElementTextItem *deti,
QUndoCommand *parent = nullptr);
~AddElementTextCommand() override;
-
+
void undo() override;
void redo() override;
-
+
private:
Element *m_element = nullptr;
DynamicElementTextItem *m_text = nullptr;
@@ -64,10 +65,10 @@ class AddTextsGroupCommand : public QUndoCommand
QList texts_list,
QUndoCommand *parent = nullptr);
~AddTextsGroupCommand() override;
-
+
void undo() override;
void redo() override;
-
+
private:
QPointer m_element;
QPointer m_group;
@@ -88,10 +89,10 @@ class RemoveTextsGroupCommand : public QUndoCommand
ElementTextItemGroup *group,
QUndoCommand *parent = nullptr);
~RemoveTextsGroupCommand() override;
-
+
void undo() override;
void redo() override;
-
+
private:
QPointer m_element;
QPointer m_group;
@@ -108,10 +109,10 @@ class AddTextToGroupCommand : public QUndoCommand
ElementTextItemGroup *group,
QUndoCommand *parent = nullptr);
~AddTextToGroupCommand() override;
-
+
void undo() override;
void redo() override;
-
+
private:
QPointer m_text;
QPointer m_group;
@@ -128,10 +129,10 @@ class RemoveTextFromGroupCommand : public QUndoCommand
ElementTextItemGroup *group,
QUndoCommand *parent = nullptr);
~RemoveTextFromGroupCommand() override;
-
+
void undo() override;
void redo() override;
-
+
private:
QPointer m_text;
QPointer m_group;
@@ -148,12 +149,12 @@ class AlignmentTextsGroupCommand : public QUndoCommand
Qt::Alignment new_alignment,
QUndoCommand *parent = nullptr);
~AlignmentTextsGroupCommand() override;
-
+
int id() const override{return 6;}
bool mergeWith(const QUndoCommand *other) override;
void undo() override;
void redo() override;
-
+
private:
QPointer m_group;
Qt::Alignment m_previous_alignment,
diff --git a/sources/undocommand/deleteqgraphicsitemcommand.h b/sources/undocommand/deleteqgraphicsitemcommand.h
index 7466e2ac3..b2c3ba400 100644
--- a/sources/undocommand/deleteqgraphicsitemcommand.h
+++ b/sources/undocommand/deleteqgraphicsitemcommand.h
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -19,6 +19,8 @@
#define DELETEQGRAPHICSITEMCOMMAND_H
#include
+#include
+
#include "diagramcontent.h"
class Diagram;
@@ -32,17 +34,17 @@ class DeleteQGraphicsItemCommand : public QUndoCommand
public:
DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr);
~DeleteQGraphicsItemCommand() override;
-
+
private:
DeleteQGraphicsItemCommand(const DeleteQGraphicsItemCommand &);
-
+
void setPotentialsOfRemovedElements();
Terminal *terminalInSamePotential(Terminal *terminal, Conductor *conductor_to_exclude);
public:
void undo() override;
void redo() override;
-
+
// attributes
private:
DiagramContent m_removed_contents;
diff --git a/sources/undocommand/rotateselectioncommand.h b/sources/undocommand/rotateselectioncommand.h
index bdf1d1b76..921bcac63 100644
--- a/sources/undocommand/rotateselectioncommand.h
+++ b/sources/undocommand/rotateselectioncommand.h
@@ -1,17 +1,17 @@
/*
Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech.
-
+
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
-
+
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
@@ -20,6 +20,7 @@
#include
#include
+#include
class Diagram;
class ConductorTextItem;
@@ -35,16 +36,16 @@ class RotateSelectionCommand : public QUndoCommand
RotateSelectionCommand(Diagram *diagram, qreal angle=90, QUndoCommand *parent=nullptr);
void undo() override;
void redo() override;
-
+
bool isValid();
-
+
private:
Diagram *m_diagram =nullptr;
-
+
QList> m_cond_text;
QHash m_rotate_by_user;
QList m_undo;
-
+
};
#endif // ROTATESELECTIONCOMMAND_H
diff --git a/sources/undocommand/rotatetextscommand.h b/sources/undocommand/rotatetextscommand.h
index 8ee37f3d3..2bbc80c24 100644
--- a/sources/undocommand/rotatetextscommand.h
+++ b/sources/undocommand/rotatetextscommand.h
@@ -20,6 +20,7 @@
#include
#include
+#include
class ConductorTextItem;
class Diagram;
@@ -34,14 +35,14 @@ class RotateTextsCommand : public QUndoCommand
{
public:
RotateTextsCommand(Diagram *diagram, QUndoCommand *parent=nullptr);
-
+
void undo() override;
void redo() override;
-
+
private:
void openDialog();
void setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end);
-
+
private:
QPointer m_diagram;
QHash m_cond_texts;