Merge branch 'master' of ssh://git.tuxfamily.org/gitroot/qet/qet

This commit is contained in:
artgg7300
2020-09-23 17:53:01 +02:00
63 changed files with 1577 additions and 1458 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -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 += .

View File

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

View File

@@ -18,8 +18,10 @@
#ifndef NAMELISTWIDGET_H
#define NAMELISTWIDGET_H
#include "nameslist.h"
#include <QWidget>
#include <QHash>
#include "nameslist.h"
namespace Ui {
class NameListWidget;

View File

@@ -20,7 +20,6 @@
#include <QRectF>
#include <QLineF>
#include <QColor>
#include <QPolygonF>
class QPainter;

View File

@@ -16,9 +16,10 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "numerotationcontext.h"
#include "qet.h"
#include <utility>
#include "qet.h"
#include <QRegularExpression>
/**
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())));
}
/**

View File

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

View File

@@ -17,6 +17,8 @@
*/
#include <QPainter>
#include <utility>
#include <QLocale>
#include "titleblocktemplate.h"
#include "titleblocktemplaterenderer.h"
#include "bordertitleblock.h"
@@ -51,9 +53,10 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
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())) {
#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());
@@ -933,9 +936,12 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
}
// ... 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_);

View File

@@ -18,7 +18,7 @@
#include "conductorproperties.h"
#include <QPainter>
#include <QMetaEnum>
#include <QRegularExpression>
/**
Constructeur par defaut
*/
@@ -789,11 +789,12 @@ void ConductorProperties::readStyle(const QString &style_string) {
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;

View File

@@ -15,6 +15,12 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QFontDialog>
#include <QFont>
#include <QSizePolicy>
#include <utility>
#include "configpages.h"
#include "borderpropertieswidget.h"
#include "conductorpropertieswidget.h"
@@ -27,10 +33,7 @@
#include "qetproject.h"
#include "reportproperties.h"
#include "qetapp.h"
#include <QFontDialog>
#include <QFont>
#include <QSizePolicy>
#include <utility>
#include "nameslist.h"
/**
@brief NewDiagramPage::NewDiagramPage

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -24,6 +24,7 @@
#include "diagramposition.h"
#include <QSqlError>
#include <QLocale>
#if defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS)
#include <QSqlDriver>
@@ -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
}

View File

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

View File

@@ -16,9 +16,10 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "diagramcontext.h"
#include <QRegExp>
#include "qet.h"
#include <QDebug>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
/**
@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)

View File

@@ -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;
}

View File

@@ -19,7 +19,6 @@
#define DIAGRAM_POSITION_H
#include <QPointF>
#include <QString>
#include <QRegExp>
/**
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

View File

@@ -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);
}

View File

@@ -19,6 +19,8 @@
#include "elementscene.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include <QRegularExpression>
/**
@brief CustomElementGraphicPart::CustomElementGraphicPart
Default constructor.
@@ -518,12 +520,12 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
#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;

View File

@@ -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<QPointF> PartLine::fourShapePoints() const
{
const qreal marge = 2.0;
QPointF a = m_line.p1();
QPointF b = m_line.p2();
QList<QPointF> 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

View File

@@ -110,10 +110,8 @@ class PartLine : public CustomElementGraphicPart
void removeHandler();
QPainterPath path() const;
QList<QPointF> fourShapePoints() const;
QRectF firstEndCircleRect() const;
QRectF secondEndCircleRect() const;
void debugPaint(QPainter *);
/*****************/
Qet::EndType first_end;

View File

@@ -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);

View File

@@ -378,12 +378,12 @@ StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p,
updateForm();
auto main_layout = new QVBoxLayout();
main_layout -> setMargin(0);
main_layout -> setContentsMargins(0,0,0,0);
main_layout -> addWidget(new QLabel("<u>" + tr("Apparence :") + "</u> "));
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);

View File

@@ -113,7 +113,7 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
// 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);

View File

@@ -20,6 +20,7 @@
#include <QSet>
#include <QPointF>
#include <QHash>
class QGraphicsItem;
class DiagramTextItem;

View File

@@ -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<Element *> 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,99 +503,57 @@ 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<QPointF> 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
@@ -614,25 +561,24 @@ void ExportDialog::generateDxf(
{
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 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);
Createdxf::drawArcEllipse(file_path, x, y, w, h, startAngle, spanAngle, hotspot_x, hotspot_y, rotation_angle, 0);
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<Terminal *> 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;
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<QPointF> junctions_list = cond->junctions();
if (!junctions_list.isEmpty()) {
@@ -691,26 +638,34 @@ void ExportDialog::generateDxf(
qreal fontSize = dti -> font().pointSizeF();
if (fontSize < 0)
fontSize = dti -> font().pixelSize();
fontSize *= Createdxf::yScale;
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;
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);

View File

@@ -28,6 +28,7 @@
#include <iostream>
#include <QAbstractTextDocumentLayout>
#include <QGraphicsSimpleTextItem>
#include <QRegularExpression>
ElementPictureFactory* ElementPictureFactory::m_factory = nullptr;
@@ -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);

View File

@@ -77,26 +77,21 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
PropertiesEditorWidget *editor,
QWidget *parent)
{
int count_ = items.size();
//The editor widget can only edit one item
//or several items of the same type
if (count_ != 1)
{
const int count_ = items.size();
if (count_ == 0) {
return nullptr;
}
QGraphicsItem *item = items.first();
const int type_ = item->type();
int type_ = items.first()->type();
for (QGraphicsItem *qgi : items) {
//The editor widget can only edit one item
//or several items of the same type
for (auto 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();

View File

@@ -203,7 +203,6 @@ int main(int argc, char **argv)
my_ma->send_info_to_debug();
delete my_ma;
}
return app.exec();
}

View File

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

View File

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

View File

@@ -24,6 +24,7 @@
#include <QFileInfo>
#include <QSaveFile>
#include <QTextStream>
#include <QRegularExpression>
/**
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
@@ -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

View File

@@ -33,14 +33,14 @@
#include "projectview.h"
#include "elementpicturefactory.h"
#include "aboutqetdialog.h"
#include "factory/elementfactory.h"
#include <cstdlib>
#include <iostream>
#define QUOTE(x) STRINGIFY(x)
#define STRINGIFY(x) #x
#include <QProcessEnvironment>
#include "factory/elementfactory.h"
#include <QRegularExpression>
#include <KAutoSaveFile>
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
@@ -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);
}
@@ -2102,10 +2102,10 @@ template <class T> 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);
}

View File

@@ -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);
}

View File

@@ -18,6 +18,10 @@
#ifndef ELEMENT_H
#define ELEMENT_H
#include <algorithm>
#include <QPicture>
#include <QHash>
#include "qet.h"
#include "qetgraphicsitem.h"
#include "diagramcontext.h"
@@ -25,9 +29,6 @@
#include "elementslocation.h"
#include "nameslist.h"
#include <algorithm>
#include <QPicture>
class QETProject;
class Terminal;
class Conductor;

View File

@@ -966,29 +966,27 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
{
case Line:
Createdxf::drawLine(filepath,
QLineF(mapToScene(m_P1),
QLineF( mapToScene(m_P1),
mapToScene(m_P2)),
Createdxf::getcolorCode(pen.color().red(),
pen.color().green(),
pen.color().blue()));
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()));
Createdxf::dxfColor(pen));
return true;
case Ellipse:
Createdxf::drawEllipse (filepath,
Createdxf::drawEllipse(filepath,
QRectF(mapToScene(m_P1),
mapToScene(m_P2)).normalized(),
Createdxf::getcolorCode(pen.color().red(),
pen.color().green(),
pen.color().blue()));
Createdxf::dxfColor(pen));
return true;
default: return false;
case Polygon:
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
return true;
default:
return false;
}
}

View File

@@ -15,11 +15,12 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qetinformation.h"
#include <QObject>
#include <QHash>
#include "qetinformation.h"
/**
@brief QETInformation::titleblockInfoKeys
@return all available key for use with a titleblock

View File

@@ -19,6 +19,7 @@
#define QETINFORMATION_H
#include <QStringList>
#include <QHash>
namespace QETInformation
{

View File

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

View File

@@ -18,6 +18,9 @@
#ifndef QET_PROJECT_H
#define QET_PROJECT_H
#include <KAutoSaveFile>
#include <QHash>
#include "nameslist.h"
#include "elementslocation.h"
#include "borderproperties.h"
@@ -28,8 +31,6 @@
#include "projectdatabase.h"
#include "reportproperties.h"
#include <KAutoSaveFile>
class Diagram;
class ElementsLocation;
class QETResult;

View File

@@ -16,12 +16,15 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qetregexpvalidator.h"
#include <QRegularExpression>
/**
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 &regexp, QObject *parent) : QRegExpValidator(regexp, parent) {
QETRegExpValidator::QETRegExpValidator(
const QRegularExpression &regexp, 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);
}

View File

@@ -17,18 +17,18 @@
*/
#ifndef QET_REGEXP_VALIDATOR_H
#define QET_REGEXP_VALIDATOR_H
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
/**
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 &);

View File

@@ -18,7 +18,7 @@
#include "qfilenameedit.h"
#include "qetregexpvalidator.h"
#include <QKeyEvent>
#include <QRegExp>
#include <QRegularExpression>
#include <QToolTip>
/**
@@ -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(

View File

@@ -18,8 +18,8 @@
#ifndef Q_FILENAME_EDIT_H
#define Q_FILENAME_EDIT_H
#include <QLineEdit>
#include <QRegExp>
#include <QString>
#include <QRegularExpression>
class QETRegExpValidator;
/**
This class represents a textfield dedicated to input a portable filename (not
@@ -54,7 +54,7 @@ class QFileNameEdit : public QLineEdit {
// attributes
private:
QRegExp regexp_;
QRegularExpression regexp_;
QETRegExpValidator *validator_;
QString tooltip_text_;
};

View File

@@ -507,7 +507,10 @@ void QETTitleBlockTemplateEditor::initWidgets()
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_);
@@ -526,7 +529,10 @@ void QETTitleBlockTemplateEditor::initWidgets()
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);

View File

@@ -19,6 +19,8 @@
#include "templatescollection.h"
#include "qetapp.h"
#include <QRegularExpression>
// make this class usable with QVariant
int TitleBlockTemplateLocation::MetaTypeId = qRegisterMetaType<TitleBlockTemplateLocation>("TitleBlockTemplateLocation");
@@ -98,9 +100,9 @@ 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();
}

View File

@@ -20,6 +20,8 @@
#include "qetapp.h"
#include "qetproject.h"
#include <QRegularExpression>
/**
Constructor
@param parent Parent QObject
@@ -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, "");
}
@@ -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, ""));
}

View File

@@ -23,6 +23,8 @@
// uncomment the line below to get more debug information
//#define TITLEBLOCK_TEMPLATE_DEBUG
#include <QRegularExpression>
#include <QRegularExpressionMatch>
/**
@brief TitleBlockTemplate::TitleBlockTemplate
Constructor
@@ -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;
@@ -1825,7 +1834,8 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
@param h
@param color
*/
void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
void TitleBlockTemplate::renderTextCellDxf(
QString &file_path,
const QString &text,
const TitleBlockCell &cell,
qreal x,
@@ -1848,23 +1858,33 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
x2 = x; // default
if ( cell.alignment & Qt::AlignTop ) {
if ( cell.alignment & Qt::AlignTop )
{
vAlign = 3;
y1 = y + h - (textHeight*Createdxf::yScale / 8);
} else if ( cell.alignment & Qt::AlignVCenter ) {
}
else if ( cell.alignment & Qt::AlignVCenter )
{
vAlign = 2;
y1 = y + h/2;
} else if ( cell.alignment & Qt::AlignBottom ) {
}
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 ) {
}
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;
@@ -1874,7 +1894,8 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
//painter.setFont(text_font);
qreal ratio = 1.0;
if (cell.hadjust) {
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;
@@ -1884,7 +1905,8 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
}
// x offset value below currently set heuristically based on appearance...
Createdxf::drawTextAligned(file_path,
Createdxf::drawTextAligned(
file_path,
text,
x - 2*Createdxf::xScale,
y1,
@@ -2019,7 +2041,8 @@ 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;

View File

@@ -18,6 +18,8 @@
#include "diagramcontextwidget.h"
#include "ui_diagramcontextwidget.h"
#include <QRegularExpression>
DiagramContextWidget::DiagramContextWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::DiagramContextWidget)
@@ -118,7 +120,7 @@ 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);
@@ -133,7 +135,7 @@ int DiagramContextWidget::highlightNonAcceptableKeys()
bool highlight = false;
if (!qtwi_name -> text().isEmpty())
{
if (!re.exactMatch(qtwi_name -> text()))
if (re!=QRegularExpression(qtwi_name -> text()))
{
highlight = true;
++ invalid_keys;

View File

@@ -19,6 +19,8 @@
#define DYNAMICELEMENTTEXTMODEL_H
#include <QStandardItemModel>
#include <QHash>
#include <qstyleditemdelegate.h>
#include "dynamicelementtextitem.h"

View File

@@ -18,6 +18,8 @@
#ifndef LINKSINGLEELEMENTWIDGET_H
#define LINKSINGLEELEMENTWIDGET_H
#include <QHash>
#include "element.h"
#include "abstractelementpropertieseditorwidget.h"

View File

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

View File

@@ -15,13 +15,16 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QSettings>
#include <QHash>
#include "multipastedialog.h"
#include "ui_multipastedialog.h"
#include "diagram.h"
#include "diagramcommands.h"
#include "element.h"
#include "conductorautonumerotation.h"
#include <QSettings>
MultiPasteDialog::MultiPasteDialog(Diagram *diagram, QWidget *parent) :
QDialog(parent),

View File

@@ -15,11 +15,14 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QRadioButton>
#include <QHash>
#include "potentialselectordialog.h"
#include "ui_potentialselectordialog.h"
#include "conductor.h"
#include "terminal.h"
#include <QRadioButton>
#include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "diagram.h"
#include "element.h"

View File

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

View File

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

View File

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

View File

@@ -21,6 +21,7 @@
#include <QUndoCommand>
#include <QPointer>
#include <QDomElement>
#include <QHash>
class Element;
class DynamicElementTextItem;

View File

@@ -19,6 +19,8 @@
#define DELETEQGRAPHICSITEMCOMMAND_H
#include <QUndoCommand>
#include <QHash>
#include "diagramcontent.h"
class Diagram;

View File

@@ -20,6 +20,7 @@
#include <QUndoCommand>
#include <QPointer>
#include <QHash>
class Diagram;
class ConductorTextItem;

View File

@@ -20,6 +20,7 @@
#include <QUndoCommand>
#include <QPointer>
#include <QHash>
class ConductorTextItem;
class Diagram;