Compare commits

..

1 Commits

Author SHA1 Message Date
Simon De Backer
9ca60407aa Fix Wdeprecated-declarations QProcess::startDetached
QProcess::startDetached(const QString&)’ is deprecated
Use
QProcess::startDetached(const QString &program,
			const QStringList &arguments)
instead
2020-07-19 15:18:58 +02:00
43 changed files with 477 additions and 1126 deletions

5
.gitignore vendored
View File

@@ -1,7 +1,2 @@
*.snap
.flatpak-builder
# Qt build output
*.user
# doxygen Doxyfile output
doc/
QElectroTech.tag

View File

@@ -27,7 +27,6 @@
#include <QtCore/QSharedMemory>
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) // ### Qt 6: remove
#else
#pragma message("@TODO remove code for QT 5.10 or later")
#include <QRandomGenerator>
#endif
#include "singleapplication.h"
@@ -107,7 +106,6 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() );
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) );
#else
#pragma message("@TODO remove code for QT 5.10 or later")
quint32 value = QRandomGenerator::global()->generate();
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( value ) / RAND_MAX * 10 ) );
#endif

View File

@@ -641,7 +641,6 @@ void ElementsCollectionWidget::search()
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList text_list = text.split("+", QString::SkipEmptyParts);
#else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList text_list = text.split("+", Qt::SkipEmptyParts);
#endif
QModelIndexList match_index;

View File

@@ -754,7 +754,6 @@ QDebug operator<< (QDebug debug, const ElementsLocation &location)
QDebugStateSaver saver(debug);
#if QT_VERSION >= 0x050400
#pragma message("@TODO remove code for QT 5.04 or later")
debug.noquote();
#else
debug.nospace();

View File

@@ -70,7 +70,6 @@ bool ConductorNumExport::toCsv()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << wiresNum() << endl;
#else
#pragma message("@TODO remove code for QT 5.15 or later")
stream << wiresNum() << &Qt::endl(stream);
#endif
}

View File

@@ -331,23 +331,12 @@ void ConductorProperties::fromXml(QDomElement &e)
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
m_horizontal_alignment = Qt::Alignment(
me.keyToValue(
e.attribute(
"horizontal-alignment",
"AlignBottom"
).toStdString().data()));
m_vertical_alignment = Qt::Alignment(
me.keyToValue(
e.attribute(
"vertical-alignment",
"AlignRight"
).toStdString().data()));
m_horizontal_alignment = Qt::Alignment(me.keyToValue(e.attribute("horizontal-alignment", "AlignBottom").toStdString().data()));
m_vertical_alignment = Qt::Alignment(me.keyToValue(e.attribute("vertical-alignment", "AlignRight").toStdString().data()));
//Keep retrocompatible with version older than 0,4
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
//@TODO remove this code for qet 0.6 or later
#pragma message("@TODO remove this code for qet 0.6 or later")
//Keep retrocompatible with version older than 0,4
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
//@TODO remove this code for qet 0.6 or later
if (e.attribute("type") == "simple") m_show_text = false;
}
@@ -765,7 +754,6 @@ void ConductorProperties::readStyle(const QString &style_string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
#else
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
#endif

View File

@@ -25,7 +25,6 @@
class QPainter;
/**
@brief The SingleLineProperties class
This class represents the properties of a singleline conductor.
*/
class SingleLineProperties {
@@ -60,7 +59,6 @@ class SingleLineProperties {
};
/**
@brief The ConductorProperties class
This class represents the functional properties of a particular conductor,
i.e. properties other than path and terminals.
*/
@@ -71,15 +69,14 @@ class ConductorProperties
virtual ~ConductorProperties();
/**
@brief The ConductorType enum Represents
the kind of a particular conductor:
Single: singleline symbols, no text input
Multi: text input, no symbol
*/
* @brief The ConductorType enum Represents the kind of a particular conductor:
* Single: singleline symbols, no text input
* Multi: text input, no symbol
*/
enum ConductorType { Single, Multi };
//Attributes
//Attributes
ConductorType type;
QColor color,
@@ -111,7 +108,7 @@ class ConductorProperties
SingleLineProperties singleLineProperties;
// methods
// methods
void toXml(QDomElement &) const;
void fromXml(QDomElement &);
void toSettings(QSettings &, const QString & = QString()) const;
@@ -121,7 +118,7 @@ class ConductorProperties
static ConductorProperties defaultProperties();
// operators
// operators
bool operator==(const ConductorProperties &) const;
bool operator!=(const ConductorProperties &) const;

View File

@@ -15,74 +15,46 @@
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QScrollArea>
#include "configdialog.h"
#include "configpages.h"
#include "qetapp.h"
#include "machine_info.h"
/**
Constructeur
@param parent QWidget parent
*/
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
Machine_info *mymachineinfo= new Machine_info(this);
//ScrollArea for low screens
QScrollArea *scroll = new QScrollArea(this);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// liste des pages
pages_list = new QListWidget();
pages_list -> setViewMode(QListView::IconMode);
if(mymachineinfo->get_max_screen_height()<1000){
pages_list -> setIconSize(QSize(64, 64));
} else {
pages_list -> setIconSize(QSize(128, 128));
}
pages_list -> setIconSize(QSize(128, 128));
pages_list -> setMovement(QListView::Static);
pages_list -> setMinimumWidth(168);
pages_list -> setMaximumWidth(168);
pages_list -> setSpacing(16);
pages_list -> setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
pages_list -> setMinimumWidth(168);
pages_list -> setMaximumWidth(168);
pages_list -> setSpacing(16);
pages_list -> setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// pages
pages_widget = new QStackedWidget();
// boutons
buttons = new QDialogButtonBox(
QDialogButtonBox::Ok
|QDialogButtonBox::Cancel);
QWidget *viewport = new QWidget(this);
scroll->setWidget(viewport);
scroll->setWidgetResizable(true);
buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
// layouts
QHBoxLayout *hlayout1 = new QHBoxLayout(viewport);
// add needed widgets to layout "hlayout1"
QHBoxLayout *hlayout1 = new QHBoxLayout();
hlayout1 -> addWidget(pages_list);
hlayout1 -> addWidget(pages_widget);
//add hlayout1 to widget
viewport->setLayout(hlayout1);
// Add a layout for QDialog
QVBoxLayout *dialog_layout = new QVBoxLayout(this);
dialog_layout->addWidget(scroll); // add scroll to the QDialog's layout
dialog_layout -> addWidget(buttons);
setLayout(dialog_layout);
QVBoxLayout *vlayout1 = new QVBoxLayout();
vlayout1 -> addLayout(hlayout1);
vlayout1 -> addWidget(buttons);
setLayout(vlayout1);
// connexion signaux / slots
connect(buttons, SIGNAL(accepted()), this, SLOT(applyConf()));
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
connect(pages_list, SIGNAL(currentRowChanged(int)),
pages_widget, SLOT(setCurrentIndex(int)));
resize(mymachineinfo->get_max_screen_width(),
mymachineinfo->get_max_screen_height());
connect(pages_list, SIGNAL(currentRowChanged(int)), pages_widget, SLOT(setCurrentIndex(int)));
#ifdef Q_OS_MACOS
if (parent) {
setWindowFlags(Qt::Sheet);

View File

@@ -46,7 +46,6 @@ ElementQueryWidget::ElementQueryWidget(QWidget *parent) :
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id)
#else
#pragma message("@TODO remove code for QT 5.15 or later")
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id)
#endif
{

View File

@@ -1141,7 +1141,6 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
content_ptr -> m_images = added_images.toSet();
content_ptr -> m_shapes = added_shapes.toSet();
#else
#pragma message("@TODO remove code for QT 5.14 or later")
content_ptr -> m_text_fields = QSet<IndependentTextItem *>(
added_texts.begin(),
added_texts.end());

View File

@@ -416,7 +416,6 @@ void ChangeZValueCommand::applyRaise(const QList<QGraphicsItem *> &items_list) {
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) // ### Qt 6: remove
my_items_list.swap(i, i + 1);
#else
#pragma message("@TODO remove code for QT 5.13 or later")
my_items_list.swapItemsAt(i, i + 1);
#endif
}
@@ -439,7 +438,6 @@ void ChangeZValueCommand::applyLower(const QList<QGraphicsItem *> &items_list) {
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) // ### Qt 6: remove
my_items_list.swap(i, i - 1);
#else
#pragma message("@TODO remove code for QT 5.13 or later")
my_items_list.swapItemsAt(i, i - 1);
#endif
}

View File

@@ -498,7 +498,6 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
#else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
#endif

View File

@@ -51,9 +51,8 @@ ElementsCollectionCache::ElementsCollectionCache(const QString &database_path, Q
cache_db_.exec("PRAGMA locking_mode = EXCLUSIVE");
cache_db_.exec("PRAGMA synchronous = OFF");
//TODO This code remove old table with mtime for create table with uuid, created at version 0,5
//see to remove this code at version 0,6 or 0,7 when all users will table with uuid.
#pragma message("@TODO remove this code for qet 0.6 or later")
//TODO This code remove old table with mtime for create table with uuid, created at version 0,5
//see to remove this code at version 0,6 or 0,7 when all users will table with uuid.
QSqlQuery table_name(cache_db_);
if (table_name.exec("PRAGMA table_info(names)"))
{

View File

@@ -559,7 +559,6 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
const QStringList styles = dom.attribute("style").split(";", QString::SkipEmptyParts);
#else
#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*$");

View File

@@ -1,85 +0,0 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#include "machine_info.h"
#include <QScreen>
#include <QApplication>
/**
@brief Machine_info::Machine_info
@param parent
*/
Machine_info::Machine_info(QObject *parent) : QObject(parent)
{
init_get_Screen_info();
}
/**
@brief Machine_info::init_get_Screen_info
Finds the largest screen and saves the values
*/
void Machine_info::init_get_Screen_info()
{
const auto screens = qApp->screens();
for (int ii = 0; ii < screens.count(); ++ii)
{
if(
Max_screen_width
<
screens[ii]->geometry().width()
*
screens[ii]->devicePixelRatio()
)
{
Max_screen_width =
screens[ii]->geometry().width()
*
screens[ii]->devicePixelRatio();
}
if(
Max_screen_height
<
screens[ii]->geometry().height()
*
screens[ii]->devicePixelRatio()
)
{
Max_screen_height =
screens[ii]->geometry().height()
*
screens[ii]->devicePixelRatio();
}
}
}
/**
@brief Machine_info::get_max_screen_width
@return max screen width
*/
int32_t Machine_info::get_max_screen_width()
{
return Max_screen_width;
}
/**
@brief Machine_info::get_max_screen_height
@return max screen height
*/
int32_t Machine_info::get_max_screen_height()
{
return Max_screen_height;
}

View File

@@ -1,45 +0,0 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#ifndef MACHINE_INFO_H
#define MACHINE_INFO_H
#include <QObject>
/**
@brief The Machine_info class
This class hold information from your PC.
*/
class Machine_info : public QObject
{
Q_OBJECT
public:
explicit Machine_info(QObject *parent = nullptr);
int32_t get_max_screen_width();
int32_t get_max_screen_height();
signals:
private:
void init_get_Screen_info();
int32_t Max_screen_width;
int32_t Max_screen_height;
};
#endif // MACHINE_INFO_H

View File

@@ -22,32 +22,29 @@
#include <QStyleFactory>
/**
@brief main
Main function of QElectroTech
@param argc : number of parameters
\~French number of paramètres
\~ @param argv : parameters
\~French paramètres
\~ @return exit code
*/
* @brief main
* Main function of QElectroTech
* @param argc : number of paramètres
* @param argv : paramètres
* @return
*/
int main(int argc, char **argv)
{
//Some setup, notably to use with QSetting.
//Some setup, notably to use with QSetting.
QCoreApplication::setOrganizationName("QElectroTech");
QCoreApplication::setOrganizationDomain("qelectrotech.org");
QCoreApplication::setApplicationName("QElectroTech");
//Creation and execution of the application
//HighDPI
//Creation and execution of the application
//HighDPI
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#pragma message("@TODO remove code for QT 5.6 or later")
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#else
qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
#endif
SingleApplication app(argc, argv, true);
#ifdef Q_OS_MACOS
//Handle the opening of QET when user double click on a .qet .elmt .tbt file
//or drop these same files to the QET icon of the dock
//Handle the opening of QET when user double click on a .qet .elmt .tbt file
//or drop these same files to the QET icon of the dock
MacOSXOpenEvent open_event;
app.installEventFilter(&open_event);
app.setStyle(QStyleFactory::create("Fusion"));
@@ -56,19 +53,17 @@ int main(int argc, char **argv)
if (app.isSecondary())
{
QStringList arg_list = app.arguments();
//Remove the first argument, it's the binary file
//Remove the first argument, it's the binary file
arg_list.takeFirst();
QETArguments qetarg(arg_list);
QString message = "launched-with-args: " + QET::joinWithSpaces(
QStringList(qetarg.arguments()));
QString message = "launched-with-args: " + QET::joinWithSpaces(QStringList(qetarg.arguments()));
app.sendMessage(message.toUtf8());
return 0;
}
QETApp qetapp;
QETApp::instance()->installEventFilter(&qetapp);
QObject::connect(&app, &SingleApplication::receivedMessage,
&qetapp, &QETApp::receiveMessage);
QObject::connect(&app, &SingleApplication::receivedMessage, &qetapp, &QETApp::receiveMessage);
return app.exec();
}

View File

@@ -69,7 +69,6 @@ bool nomenclature::saveToCSVFile()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << getNomenclature() << endl;
#else
#pragma message("@TODO remove code for QT 5.15 or later")
stream << getNomenclature() << &Qt::endl(stream);
#endif
}

View File

@@ -17,16 +17,6 @@
*/
#include "propertiesinterface.h"
/**
@brief PropertiesInterface::PropertiesInterface
*/
PropertiesInterface::PropertiesInterface()
{
}
/**
@brief PropertiesInterface::~PropertiesInterface
*/
PropertiesInterface::~PropertiesInterface()
{
}

View File

@@ -23,45 +23,19 @@
#include <QDomElement>
/**
@brief The PropertiesInterface class
This class is an interface for have common way
to use properties in QElectroTech
*/
* @brief The PropertiesInterface class
* This class is an interface for have common way to use properties in QElectroTech
*/
class PropertiesInterface
{
public:
PropertiesInterface();
virtual ~PropertiesInterface();
/**
@brief toSettings
Save properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
*/
virtual void toSettings (QSettings &settings,
const QString = QString()) const =0;
/**
@brief fromSettings
load properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
*/
virtual void fromSettings (const QSettings &settings,
const QString = QString()) =0;
/**
@brief toXml
Save properties to xml element
@param xml_document
@return QDomElement
*/
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
/**
@brief fromXml
load properties to xml element
@param xml_element
@return true / false
*/
virtual bool fromXml (const QDomElement &xml_element) =0;
PropertiesInterface();
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
virtual void toSettings (QSettings &settings, const QString = QString()) const =0;
virtual void fromSettings (const QSettings &settings, const QString = QString()) =0;
// Save/load properties to xml element
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
virtual bool fromXml (const QDomElement &xml_element) =0;
};
#endif // PROPERTIESINTERFACE_H

View File

@@ -20,9 +20,6 @@
#include <QString>
/**
@brief The ReportProperties class
*/
class ReportProperties
{
public:

View File

@@ -3,16 +3,16 @@
#include <QGraphicsObject>
TerminalData::TerminalData():
PropertiesInterface()
PropertiesInterface()
{
init();
init();
}
TerminalData::TerminalData(QGraphicsObject *parent):
PropertiesInterface(),
q(parent)
PropertiesInterface(),
q(parent)
{
init();
init();
}
void TerminalData::init() {
@@ -23,114 +23,65 @@ TerminalData::~TerminalData()
}
/**
@brief TerminalData::setParent
@param parent
*/
void TerminalData::setParent(QGraphicsObject* parent)
{
q = parent;
q = parent;
}
/**
@brief TerminalData::toSettings
Save properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
*/
void TerminalData::toSettings(QSettings &settings, const QString) const
{
Q_UNUSED(settings);
}
/**
@brief TerminalData::fromSettings
load properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
*/
void TerminalData::fromSettings(const QSettings &settings, const QString)
{
Q_UNUSED(settings);
}
/**
@brief TerminalData::toXml
Save properties to xml element
write the name, number, position and orientation of the terminal
to xml_element
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_document
@return xml_element : DomElement with
the name, number, position and orientation of the terminal
*/
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
{
QDomElement xml_element = xml_document.createElement("terminal");
QDomElement xml_element = xml_document.createElement("terminal");
// write the position of the terminal
// ecrit la position de la borne
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
// ecrit la position de la borne
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
// Write name and number to XML
xml_element.setAttribute("uuid", m_uuid.toString());
xml_element.setAttribute("name", m_name);
// write the orientation of the terminal
// ecrit l'orientation de la borne
xml_element.setAttribute("orientation",
Qet::orientationToString(m_orientation));
xml_element.setAttribute("uuid", m_uuid.toString());
xml_element.setAttribute("name", m_name);
return(xml_element);
// ecrit l'orientation de la borne
xml_element.setAttribute("orientation", Qet::orientationToString(m_orientation));
// Write name and number to XML
return(xml_element);
}
/**
@brief TerminalData::fromXml
load properties to xml element
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_element
@return true if succeeded / false if the attribute is not real
*/
bool TerminalData::fromXml (const QDomElement &xml_element)
{
qreal term_x = 0.0;
qreal term_y = 0.0;
// lit la position de la borne
qreal term_x = 0.0, term_y = 0.0;
if (!QET::attributeIsAReal(xml_element, "x", &term_x))
return false;
// reads the position of the terminal
// lit la position de la borne
if (!QET::attributeIsAReal(xml_element, "x", &term_x))
return false;
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
return false;
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
return false;
m_pos = QPointF(term_x, term_y);
m_pos = QPointF(term_x, term_y);
//emit posFromXML(QPointF(term_x, term_y));
//emit posFromXML(QPointF(term_x, term_y));
QString uuid = xml_element.attribute("uuid");
// update part and add uuid, which is used in the new version to connect terminals together
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
// to identify terminals
if (!uuid.isEmpty())
m_uuid = QUuid(uuid);
QString uuid = xml_element.attribute("uuid");
// update part and add uuid, which is used in the new version
// to connect terminals together
// if the attribute not exists, means, the element is created with an
// older version of qet. So use the legacy approach
// to identify terminals
if (!uuid.isEmpty())
m_uuid = QUuid(uuid);
m_name = xml_element.attribute("name");
m_name = xml_element.attribute("name");
// lit l'orientation de la borne
m_orientation = Qet::orientationFromString(xml_element.attribute("orientation"));
// read the orientation of the terminal
// lit l'orientation de la borne
m_orientation = Qet::orientationFromString(
xml_element.attribute("orientation"));
return true;
return true;
}

View File

@@ -18,70 +18,62 @@ class QGraphicsObject;
*/
class TerminalData : public PropertiesInterface
{
public:
TerminalData();
TerminalData(QGraphicsObject* parent);
~TerminalData();
public:
TerminalData();
TerminalData(QGraphicsObject* parent);
~TerminalData();
void init();
void init();
void setParent(QGraphicsObject* parent);
void toSettings(QSettings &settings,
const QString = QString()) const override;
void fromSettings(const QSettings &settings,
const QString = QString()) override;
QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override;
void setParent(QGraphicsObject* parent);
// must be public, because this class is a private member
// of PartTerminal/Terminal and they must access this data
public:
/**
@brief m_orientation
Orientation of the terminal
*/
Qet::Orientation m_orientation;
/**
@brief second_point
Position of the second point of the terminal
in scene coordinates
*/
QPointF second_point;
/**
@brief m_uuid
Uuid of the terminal.
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
void toSettings(QSettings &settings, const QString = QString()) const override;
void fromSettings(const QSettings &settings, const QString = QString()) override;
// Save/load properties to xml element
// This method is only called from the PartTerminal and should never called from the Terminal class
QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override;
In elementscene.cpp an element gets a new uuid when
saving the element. In the current state
each connection is made by using the local position
of the terminal and a dynamic id. In the new
case, each terminal should have it's own uuid to
identify it uniquely. When changing each time this
uuid, the conductor after updating the part is anymore
valid. So if in the loaded document a uuid exists,
use this one and don't create a new one.
*/
QUuid m_uuid;
/**
@brief m_name
Name of the element.
It can be used to create wiring harness tables
*/
QString m_name;
// must be public, because this class is a private member of PartTerminal/Terminal and they must
// access this data
public:
/*!
* \brief m_orientation
* Orientation of the terminal
*/
Qet::Orientation m_orientation;
/*!
* \brief second_point
* Position of the second point of the terminal in scene coordinates
*/
QPointF second_point;
/*!
* \brief m_uuid
* Uuid of the terminal.
*
* In elementscene.cpp an element gets a new uuid when saving the element. In the current state
* each connection is made by using the local position of the terminal and a dynamic id. In the new
* case, each terminal should have it's own uuid to identify it uniquely. When changing each time this
* uuid, the conductor after updating the part is anymore valid. So if in the loaded document a uuid exists,
* use this one and don't create a new one.
*/
QUuid m_uuid;
/*!
* \brief m_name
* Name of the element. It can be used to create wiring harness tables
*/
QString m_name;
/**
@brief m_pos
Position of the terminal. The second point is calculated
from this position and the orientation
@note
Important: this variable is only updated during read
from xml and not during mouse move!
It is used to store the initial position so that
PartTerminal and Terminal have access to it.
*/
QPointF m_pos;
private:
QGraphicsObject* q{nullptr};
/*!
* \brief m_pos
* Position of the terminal. The second point is calculated from this position and the orientation
* Important: this variable is only updated during read from xml and not during mouse move!
* It is used to store the initial position so that PartTerminal and Terminal have access to it.
*/
QPointF m_pos;
private:
QGraphicsObject* q{nullptr};
};
#endif // TERMINALDATA_H

View File

@@ -176,7 +176,6 @@ bool QET::orthogonalProjection(const QPointF &point, const QLineF &line, QPointF
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectType it = line.intersect(perpendicular_line, &intersection_point); // ### Qt 6: remove
#else
#pragma message("@TODO remove code for QT 5.14 or later")
QLineF::IntersectType it = line.intersects(perpendicular_line, &intersection_point);
#endif
@@ -451,7 +450,6 @@ QStringList QET::splitWithSpaces(const QString &string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), QString::SkipEmptyParts);
#else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList escaped_strings = string.split(QRegExp("[^\\]?(?:\\\\)* "), Qt::SkipEmptyParts);
#endif

View File

@@ -309,6 +309,8 @@ void ProjectDBModel::dataBaseUpdated()
auto new_record = m_record;
m_record = original_record;
//This a very special case, if this nomenclature model is added
//befor any element, column count return 0, so in this case we emit column inserted
if (new_record.size() != m_record.size())
{
emit beginResetModel();

View File

@@ -61,56 +61,6 @@ void QetGraphicsTableItem::adjustTableToFolio(QetGraphicsTableItem *table, QMarg
table->setDisplayNRow(int(floor(available_height/min_row_height))); //Convert a double to int, but max_row_to_display is already rounded an integer so we assume everything is ok
}
/**
* @brief QetGraphicsTableItem::checkInsufficientRowsCount
* Check if the number of rows of @table + linked table is enough to display all
* content of the model, if not open a dialog to advise user what to do.
* @param table
*/
void QetGraphicsTableItem::checkInsufficientRowsCount(QetGraphicsTableItem *table)
{
if (!table->diagram() || !table->model()) {
return;
}
auto first_table = table;
while (first_table->previousTable())
first_table = first_table->previousTable();
if (first_table->displayNRow() <= 0) //displayed rows is unlimited
return;
int count_ = first_table->displayNRow();
bool several_table = false;
while (first_table->nextTable())
{
several_table = true;
first_table = first_table->nextTable();
if (first_table->displayNRow() <= 0) { //displayed rows is unlimited
return;
} else {
count_ += first_table->displayNRow();
first_table->displayNRowOffset();
}
}
if (count_ < first_table->model()->rowCount())
{
QWidget *parent = first_table->diagram()->views().first() ? first_table->diagram()->views().first() : nullptr;
QString text;
if (several_table) {
text = tr("Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par les tableaux.\n"
"Veuillez ajouter un nouveau tableau ou regler les tableaux existant afin d'afficher l'integralité des informations.");
} else {
text = tr("Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par le tableau.\n"
"Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'afficher l'integralité des informations.");
}
QMessageBox::information(parent, tr("Limitation de tableau"), text);
}
}
/**
* @brief QetGraphicsTableItem::QetGraphicsTableItem
* Default constructor
@@ -651,10 +601,6 @@ QVariant QetGraphicsTableItem::itemChange(QGraphicsItem::GraphicsItemChange chan
void QetGraphicsTableItem::modelReseted() {
dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>());
setToMinimumHeight();
if (!previousTable()) { //this is the head table
checkInsufficientRowsCount(this);
}
}
/**

View File

@@ -48,7 +48,6 @@ class QetGraphicsTableItem : public QetGraphicsItem
public :
static void adjustTableToFolio(QetGraphicsTableItem *table, QMargins margins = QMargins(20,20,20,0));
static void checkInsufficientRowsCount(QetGraphicsTableItem *first_table);
public:
QetGraphicsTableItem(QGraphicsItem *parent= nullptr);

View File

@@ -52,8 +52,6 @@ GraphicsTablePropertiesEditor::GraphicsTablePropertiesEditor(QetGraphicsTableIte
if (table) {
setTable(table);
}
ui->m_info_label->setStyleSheet("QLabel {color : red; }");
}
/**
@@ -283,8 +281,6 @@ void GraphicsTablePropertiesEditor::updateUi()
}
}
updateInfoLabel();
auto margin = QETUtils::marginsFromString(m_table_item->model()->headerData(0, Qt::Horizontal, Qt::UserRole+1).toString());
ui->m_header_top_margin ->setValue(margin.top());
ui->m_header_left_margin ->setValue(margin.left());
@@ -310,38 +306,6 @@ void GraphicsTablePropertiesEditor::updateUi()
setUpEditConnection();
}
void GraphicsTablePropertiesEditor::updateInfoLabel()
{
auto table_ = m_table_item;
while (table_->previousTable()) { table_ = table_->previousTable();}
int count_ = 0;
bool infinite = false;
if (table_->displayNRow() <= 0) {
infinite = true;
} else {
count_ = table_->displayNRow();
}
while (table_->nextTable())
{
table_ = table_->nextTable();
if (table_->displayNRow() <= 0) {
infinite = true;
} else {
count_ += table_->displayNRow();
}
}
auto value = m_table_item->model()->rowCount() - count_;
if (value > 0 && !infinite) {
ui->m_info_label->setText(tr("<center>ATTENTION :</center>\n il manque %1 lignes afin d'afficher l'intégralité des informations").arg(value));
ui->m_info_label->show();
} else {
ui->m_info_label->hide();
}
}
/**
* @brief GraphicsTablePropertiesEditor::setUpEditConnection
*/
@@ -369,12 +333,10 @@ void GraphicsTablePropertiesEditor::setUpEditConnection()
m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &GraphicsTablePropertiesEditor::apply);
#else
#pragma message("@TODO remove code for QT 5.15 or later")
m_edit_connection << connect(m_table_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(m_header_button_group, QOverload<int>::of(&QButtonGroup::idClicked), this, &GraphicsTablePropertiesEditor::apply);
#endif
m_edit_connection << connect(ui->m_display_n_row_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &GraphicsTablePropertiesEditor::apply);
m_edit_connection << connect(ui->m_display_n_row_sb, QOverload<int>::of(&QSpinBox::valueChanged), this, &GraphicsTablePropertiesEditor::updateInfoLabel);
}
}

View File

@@ -52,7 +52,6 @@ class GraphicsTablePropertiesEditor : public PropertiesEditorWidget
void on_m_header_font_pb_clicked();
void on_m_table_font_pb_clicked();
virtual void updateUi() override;
void updateInfoLabel();
void on_m_table_name_le_textEdited(const QString &arg1);
void on_m_previous_table_cb_activated(int index);
void on_m_previous_pb_clicked();

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>524</width>
<height>623</height>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
@@ -40,17 +40,40 @@
<string>Géometrie et lignes</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0,0,0,0,0,0">
<item row="1" column="4">
<widget class="QSpinBox" name="m_display_n_row_sb">
<property name="specialValueText">
<string>Toutes</string>
<item row="0" column="6">
<widget class="QPushButton" name="m_apply_geometry_to_linked_table_pb">
<property name="toolTip">
<string>Appliquer la géometrie à tous les tableaux liée à celui-ci</string>
</property>
<property name="maximum">
<number>999</number>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/all_pages.png</normaloff>:/ico/22x22/all_pages.png</iconset>
</property>
</widget>
</item>
<item row="2" column="6">
<item row="1" column="2">
<widget class="QSpinBox" name="m_y_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="m_previous_table_cb">
<property name="insertPolicy">
<enum>QComboBox::InsertAtBottom</enum>
</property>
<item>
<property name="text">
<string>Aucun</string>
</property>
</item>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="m_next_pb">
<property name="enabled">
<bool>true</bool>
@@ -70,19 +93,14 @@
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QComboBox" name="m_previous_table_cb">
<property name="insertPolicy">
<enum>QComboBox::InsertAtBottom</enum>
<item row="0" column="2">
<widget class="QSpinBox" name="m_x_pos">
<property name="maximum">
<number>10000</number>
</property>
<item>
<property name="text">
<string>Aucun</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -95,7 +113,20 @@
</property>
</spacer>
</item>
<item row="1" column="5">
<item row="1" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="m_auto_geometry_pb">
<property name="toolTip">
<string>Ajuster le tableau au folio</string>
@@ -109,47 +140,7 @@
</property>
</widget>
</item>
<item row="2" column="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Y :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>X :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="m_x_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="4" column="1" colspan="6">
<item row="2" column="1" colspan="6">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
@@ -167,7 +158,47 @@
</layout>
</widget>
</item>
<item row="2" column="5">
<item row="0" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Lignes à afficher :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>X :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QSpinBox" name="m_display_n_row_sb">
<property name="specialValueText">
<string>Toutes</string>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Tableau précédent :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="m_previous_pb">
<property name="enabled">
<bool>true</bool>
@@ -187,60 +218,16 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="m_y_pos">
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="m_apply_geometry_to_linked_table_pb">
<property name="toolTip">
<string>Appliquer la géometrie à tous les tableaux liée à celui-ci</string>
</property>
<item row="1" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../qelectrotech.qrc">
<normaloff>:/ico/22x22/all_pages.png</normaloff>:/ico/22x22/all_pages.png</iconset>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Tableau précédent :</string>
<string>Y :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Lignes à afficher :</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1" colspan="6">
<widget class="QLabel" name="m_info_label">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -1675,7 +1675,6 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
other_conductors += other_conductors_list_t.toSet();
#else
#pragma message("@TODO remove code for QT 5.14 or later")
other_conductors += QSet<Conductor*>(other_conductors_list_t.begin(),other_conductors_list_t.end());
#endif
}

View File

@@ -826,7 +826,6 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
* this mean the label was made before commit 4791 (0.51 dev). So we swap the value stored in "label" to "formula" as expected.
* @TODO remove this code at version 0.7 or more (probably useless).
*/
#pragma message("@TODO remove this code for qet 0.7 or later")
if (dc["label"].toString().contains("%") && dc["formula"].toString().isNull())
{
dc.addValue("formula", dc["label"]);

View File

@@ -23,13 +23,12 @@
#include <QFont>
/**
@brief QETXML::penToXml
Write attribute of a QPen in xml element
@param parent_document : parent document for create the QDomElement
@param pen : the pen to store
@return : A QDomElement with the attribute stored.
The tagName of QDomeElement is "pen".
*/
* @brief QETXML::penToXml
* Write attribute of a QPen in xml element
* @param parent_document : parent document for create the QDomElement
* @param pen : the pen to store
* @return : A QDomElement with the attribute stored. The tagName of QDomeElement is "pen".
*/
QDomElement QETXML::penToXml(QDomDocument &parent_document,const QPen& pen)
{
QDomElement element = parent_document.createElement("pen");
@@ -49,19 +48,19 @@ QDomElement QETXML::penToXml(QDomDocument &parent_document,const QPen& pen)
element.setAttribute("style", style);
element.setAttribute("color", pen.color().name());
element.setAttribute("widthF", QString::number(pen.widthF()));
return element;
return element;
}
/**
@brief QETXML::penFromXml
Build a QPen from a xml description
@param element, The QDomElement that describe the pen
@return the created pen. If @element is null or tagName isn't "pen"
return a default constructed QPen
*/
* @brief QETXML::penFromXml
* Build a QPen from a xml description
* @param element, The QDomElement that describe the pen
* @return the created pen. If @element is null or tagName isn't "pen"
* return a default constructed QPen
*/
QPen QETXML::penFromXml(const QDomElement &element)
{
QPen pen;
QPen pen;
if (!(!element.isNull() && element.tagName() == "pen"))
{
@@ -83,19 +82,17 @@ QPen QETXML::penFromXml(const QDomElement &element)
pen.setColor(QColor(element.attribute("color", "#000000")));
pen.setWidthF(element.attribute("widthF", "1").toDouble());
return pen;
return pen;
}
/**
@brief QETXML::brushToXml
Write attribute of a QBrush in xml element
@param parent_document : parent document for create the QDomElement
@param brush : the brush to store
@return A QDomElement with the attribute stored.
The tagName of QDomeElement is "brush".
*/
QDomElement QETXML::brushToXml(QDomDocument &parent_document,
const QBrush& brush)
* @brief QETXML::brushToXml
* Write attribute of a QBrush in xml element
* @param parent_document : parent document for create the QDomElement
* @param brush : the brush to store
* @return A QDomElement with the attribute stored. The tagName of QDomeElement is "brush".
*/
QDomElement QETXML::brushToXml(QDomDocument &parent_document, const QBrush& brush)
{
QDomElement element = parent_document.createElement("brush");
@@ -117,7 +114,7 @@ QDomElement QETXML::brushToXml(QDomDocument &parent_document,
case Qt::BDiagPattern : style = "BDiagPattern"; break;
case Qt::FDiagPattern : style = "FDiagPattern"; break;
case Qt::DiagCrossPattern : style = "DiagCrossPattern"; break;
default : style = "Unknown"; break;
default : style = "Unknown"; break;
}
element.setAttribute("style", style);
@@ -126,12 +123,12 @@ QDomElement QETXML::brushToXml(QDomDocument &parent_document,
}
/**
@brief QETXML::brushFromXml
Build a QBrush from a xml description
@param element, the QDomElement that describe the pen
@return the created brush. If @element is null or tagName isn't "brush"
return a default constructed QBrush
*/
* @brief QETXML::brushFromXml
* Build a QBrush from a xml description
* @param element, the QDomElement that describe the pen
* @return the created brush. If @element is null or tagName isn't "brush"
* return a default constructed QBrush
*/
QBrush QETXML::brushFromXml(const QDomElement &element)
{
QBrush brush;
@@ -161,20 +158,15 @@ QBrush QETXML::brushFromXml(const QDomElement &element)
}
/**
@brief QETXML::fileSystemDirToXmlCollectionDir
@param document : owner document of returned QDomElement,
use to create the QDomElement.
@param dir : file system direcory to convert to QDomElement directory
@param rename : by default the attribute "name" of the returned
QDomElement is the same name of @dir
but we can override itwith @rename
@return A file system directory converted to a QDomElement directory
ready to be inserted into a XmlElementCollection.
If the QDomElement can't be created, return a null QDomElement.
*/
QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document,
const QDir &dir,
const QString& rename)
* @brief QETXML::fileSystemDirToXmlCollectionDir
* @param document : owner document of returned QDomElement, use to create the QDomElement.
* @param dir : file system direcory to convert to QDomElement directory
* @param rename : by default the attribute "name" of the returned QDomElement is the same name of @dir
* but we can override itwith @rename
* @return A file system directory converted to a QDomElement directory ready to be inserted into a XmlElementCollection.
* If the QDomElement can't be created, return a null QDomElement.
*/
QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document, const QDir &dir, const QString& rename)
{
if (!dir.exists()) return QDomElement();
@@ -183,9 +175,7 @@ QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document,
//Get the traduction of this directory
QFile qet_dir(dir.filePath("qet_directory"));
if (qet_dir.exists() && qet_dir.open(
QIODevice::ReadOnly
| QIODevice::Text))
if (qet_dir.exists() && qet_dir.open(QIODevice::ReadOnly | QIODevice::Text))
{
//Get the content of the file
QDomDocument trad_document;
@@ -206,21 +196,15 @@ QDomElement QETXML::fileSystemDirToXmlCollectionDir(QDomDocument &document,
}
/**
@brief QETXML::fileSystemElementToXmlCollectionElement
@param document : owner document of returned QDomElement,
use to create the QDomElement.
@param file : file system element file to convert to QDomElement;
@param rename : by default the attribute "name" of
the returned QDomElement is the same name of @file
but we can override itwith @rename
@return A file system element converted to a QDomElement
ready to be inserted into a XmlElementCollection
If the QDomElement can't be created, return a null QDomElement
*/
QDomElement QETXML::fileSystemElementToXmlCollectionElement(
QDomDocument &document,
QFile &file,
const QString& rename)
* @brief QETXML::fileSystemElementToXmlCollectionElement
* @param document : owner document of returned QDomElement, use to create the QDomElement.
* @param file : file system element file to convert to QDomElement;
* @param rename : by default the attribute "name" of the returned QDomElement is the same name of @file
* but we can override itwith @rename
* @return A file system element converted to a QDomElement ready to be inserted into a XmlElementCollection
* If the QDomElement can't be created, return a null QDomElement
*/
QDomElement QETXML::fileSystemElementToXmlCollectionElement(QDomDocument &document, QFile &file, const QString& rename)
{
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text))
{
@@ -245,32 +229,26 @@ QDomElement QETXML::fileSystemElementToXmlCollectionElement(
}
/**
@brief QETXML::writeXmlFile
Export an XML document to an UTF-8 text file indented with 4 spaces,
with LF end of lines and no BOM.
@param xml_document : An XML document to be exported
@param file_path : Path to the file to be written
@param error_message : If non-zero, will contain an error message
explaining what happened when this function returns false.
@return false if an error occurred, true otherwise
*/
bool QETXML::writeXmlFile(const QDomDocument &xml_document,
const QString &file_path,
QString *error_message)
* @brief QETXML::writeXmlFile
* Export an XML document to an UTF-8 text file indented with 4 spaces, with LF end of lines and no BOM.
* @param xml_document : An XML document to be exported
* @param file_path : Path to the file to be written
* @param error_message : If non-zero, will contain an error message explaining what happened when this function returns false.
* @return false if an error occurred, true otherwise
*/
bool QETXML::writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message)
{
QFile file(file_path);
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
bool file_opening = file.open(QIODevice::WriteOnly);
if (!file_opening)
{
if (error_message)
{
*error_message = QString(
QObject::tr(
"Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file")
).arg(file_path).arg(file.error());
*error_message = QString(QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file")
).arg(file_path).arg(file.error());
}
return(false);
}
@@ -285,17 +263,14 @@ bool QETXML::writeXmlFile(const QDomDocument &xml_document,
}
/**
@brief QETXML::textToDomElement
Return a QDomElement, created from @document,
with tag name @tag_name and text @value.
@param document
@param tag_name
@param value
@return a QDomElement, created from @document
*/
QDomElement QETXML::textToDomElement(QDomDocument &document,
const QString& tag_name,
const QString& value)
* @brief QETXML::textToDomElement
* Return a QDomElement, created from @document, with tag name @tag_name and text @value.
* @param document
* @param tag_name
* @param value
* @return
*/
QDomElement QETXML::textToDomElement(QDomDocument &document, const QString& tag_name, const QString& value)
{
QDomElement element = document.createElement(tag_name);
QDomText text = document.createTextNode(value);
@@ -305,19 +280,15 @@ QDomElement QETXML::textToDomElement(QDomDocument &document,
}
/**
@brief QETXML::directChild
@param element
@param tag_name
@return All direct child of @element with the tag name @tag_name
*/
QVector<QDomElement> QETXML::directChild(const QDomElement &element,
const QString &tag_name)
* @brief QETXML::directChild
* @param element
* @param tag_name
* @return All direct child of @element with the tag name @tag_name
*/
QVector<QDomElement> QETXML::directChild(const QDomElement &element, const QString &tag_name)
{
QVector<QDomElement> return_list;
for (
QDomNode node = element.firstChild() ;
!node.isNull() ;
node = node.nextSibling())
for (QDomNode node = element.firstChild() ; !node.isNull() ; node = node.nextSibling())
{
if (!node.isElement()) continue;
QDomElement element = node.toElement();
@@ -329,34 +300,25 @@ QVector<QDomElement> QETXML::directChild(const QDomElement &element,
}
/**
@brief QETXML::subChild
@param element
@param parent_tag_name
@param children_tag_name
@return When given an xml dom element @element,
returns a vector of all children dom_elements tagged @children_tag_name
nested in the parent dom elements tagged parent_tag_name,
themselves children of the dom element @element.
*/
QVector<QDomElement> QETXML::subChild(const QDomElement &element,
const QString parent_tag_name,
const QString &children_tag_name)
* @brief QETXML::subChild
* @param element
* @param parent_tag_name
* @param children_tag_name
* @return When given an xml dom element @element,
* returns a vector of all children dom_elements tagged @children_tag_name
* nested in the parent dom elements tagged parent_tag_name, themselves children of the dom element @element.
*/
QVector<QDomElement> QETXML::subChild(const QDomElement &element, const QString parent_tag_name, const QString &children_tag_name)
{
QVector<QDomElement> return_list;
for (
QDomNode child = element.firstChild() ;
!child.isNull() ;
child = child.nextSibling())
for (QDomNode child = element.firstChild() ; !child.isNull() ; child = child.nextSibling())
{
QDomElement parents = child.toElement();
if (parents.isNull() || parents.tagName() != parent_tag_name)
continue;
for (
QDomNode node_children = parents.firstChild() ;
!node_children.isNull() ;
node_children = node_children.nextSibling())
for (QDomNode node_children = parents.firstChild() ; !node_children.isNull() ; node_children = node_children.nextSibling())
{
QDomElement n_children = node_children.toElement();
if (!n_children.isNull() && n_children.tagName() == children_tag_name)
@@ -368,34 +330,29 @@ QVector<QDomElement> QETXML::subChild(const QDomElement &element,
}
/**
@brief QETXML::marginsToXml
Save a QMargins to xml. the xml tag name is 'margins'
@param parent_document
@param margins
@return
*/
QDomElement QETXML::marginsToXml(QDomDocument &parent_document,
const QMargins &margins)
* @brief QETXML::marginsToXml
* Save a QMargins to xml. the xml tag name is 'margins'
* @param parent_document
* @param margins
* @return
*/
QDomElement QETXML::marginsToXml(QDomDocument &parent_document, const QMargins &margins)
{
auto dom_ = parent_document.createElement("margins");
auto text_ = parent_document.createTextNode(
QString::number(margins.left())
+ QString(";")
+ QString::number(margins.top())
+ QString(";")
+ QString::number(margins.right())
+ QString(";")
+ QString::number(margins.bottom()));
auto text_ = parent_document.createTextNode(QString::number(margins.left()) + QString(";") +
QString::number(margins.top()) + QString(";") +
QString::number(margins.right()) + QString(";") +
QString::number(margins.bottom()));
dom_.appendChild(text_);
return dom_;
}
/**
@brief QETXML::marginsFromXml
@param element
@return a QMargins from an xml description.
The tag name must ne 'margins'
*/
* @brief QETXML::marginsFromXml
* @param element
* @return a QMargins from an xml description.
* The tag name must ne 'margins'
*/
QMargins QETXML::marginsFromXml(const QDomElement &element)
{
if (element.tagName() != "margins") {
@@ -404,35 +361,22 @@ QMargins QETXML::marginsFromXml(const QDomElement &element)
auto margins_ = element.text().split(";");
if (margins_.size() == 4) {
return QMargins(
margins_.at(0).toInt(),
margins_.at(1).toInt(),
margins_.at(2).toInt(),
margins_.at(3).toInt());
return QMargins(margins_.at(0).toInt(), margins_.at(1).toInt(), margins_.at(2).toInt(), margins_.at(3).toInt());
} else {
return QMargins();
}
}
/**
@brief QETXML::modelHeaderDataToXml
Save to xml element all header data specified
by @horizontal_section_role and @vertical_section_role
@param parent_document
@param model
@param horizontal_section_role : key as header section and value
as list of roles to save in xml
@param vertical_section_role :key as header section and value
as list of roles to save in xml
@return
*/
QDomElement QETXML::modelHeaderDataToXml(
QDomDocument &parent_document,
const QAbstractItemModel *model,
QHash<int,
QList<int>> horizontal_section_role,
QHash<int,
QList<int>> vertical_section_role)
* @brief QETXML::modelHeaderDataToXml
* Save to xml element all header data specified by @horizontal_section_role and @vertical_section_role
* @param parent_document
* @param model
* @param horizontal_section_role : key as header section and value as list of roles to save in xml
* @param vertical_section_role :key as header section and value as list of roles to save in xml
* @return
*/
QDomElement QETXML::modelHeaderDataToXml(QDomDocument &parent_document, const QAbstractItemModel *model, QHash<int, QList<int>> horizontal_section_role, QHash<int, QList<int>> vertical_section_role)
{
auto dom_element = parent_document.createElement("header_data");
@@ -457,11 +401,7 @@ QDomElement QETXML::modelHeaderDataToXml(
dom_data.setAttribute("role", meta_enum_role.valueToKey(role));
auto text_node = parent_document.createTextNode("");
if (role == Qt::DisplayRole
|| role == Qt::EditRole
|| role == Qt::ToolTipRole
|| role == Qt::StatusTipRole
|| role == Qt::WhatsThisRole)
if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole || role == Qt::StatusTipRole || role == Qt::WhatsThisRole)
{
text_node.setData(variant.toString());
}
@@ -493,13 +433,12 @@ QDomElement QETXML::modelHeaderDataToXml(
}
/**
@brief QETXML::modelHeaderDataFromXml
Restore from xml modele header data
@param element
@param model
*/
void QETXML::modelHeaderDataFromXml(const QDomElement &element,
QAbstractItemModel *model)
* @brief QETXML::modelHeaderDataFromXml
* Restore from xml modele header data
* @param element
* @param model
*/
void QETXML::modelHeaderDataFromXml(const QDomElement &element, QAbstractItemModel *model)
{
if (element.tagName() != "header_data")
return;
@@ -510,25 +449,12 @@ void QETXML::modelHeaderDataFromXml(const QDomElement &element,
for (auto child : QETXML::directChild(element, "data"))
{
auto section_ = child.attribute("section", "-1").toInt();
auto orientation_ = Qt::Orientation(
meta_enum_orientation.keyToValue(
child.attribute(
"orientation",
"Horizontal"
).toStdString().data()));
auto role_ = meta_enum_role.keyToValue(
child.attribute(
"role",
"DisplayRole"
).toStdString().data());
auto orientation_ = Qt::Orientation(meta_enum_orientation.keyToValue(child.attribute("orientation", "Horizontal").toStdString().data()));
auto role_ = meta_enum_role.keyToValue(child.attribute("role", "DisplayRole").toStdString().data());
auto text_ = child.text();
QVariant data_;
if (role_ == Qt::DisplayRole
|| role_ == Qt::EditRole
|| role_ == Qt::ToolTipRole
|| role_ == Qt::StatusTipRole
|| role_ == Qt::WhatsThisRole) {
if (role_ == Qt::DisplayRole || role_ == Qt::EditRole || role_ == Qt::ToolTipRole || role_ == Qt::StatusTipRole || role_ == Qt::WhatsThisRole) {
data_ = text_;
}
else if (role_ == Qt::FontRole)

View File

@@ -31,48 +31,27 @@ class QAbstractItemModel;
*/
namespace QETXML
{
QDomElement penToXml(QDomDocument &parent_document, const QPen& pen);
QPen penFromXml (const QDomElement &element);
QDomElement penToXml(QDomDocument &parent_document, const QPen& pen);
QPen penFromXml (const QDomElement &element);
QDomElement brushToXml (QDomDocument &parent_document,
const QBrush& brush);
QDomElement brushToXml (QDomDocument &parent_document, const QBrush& brush);
QBrush brushFromXml (const QDomElement &element);
QDomElement fileSystemDirToXmlCollectionDir (
QDomDocument &document,
const QDir &dir,
const QString& rename = QString());
QDomElement fileSystemElementToXmlCollectionElement (
QDomDocument &document,
QFile &file,
const QString& rename = QString());
QDomElement fileSystemDirToXmlCollectionDir (QDomDocument &document, const QDir &dir, const QString& rename = QString());
QDomElement fileSystemElementToXmlCollectionElement (QDomDocument &document, QFile &file, const QString& rename = QString());
bool writeXmlFile(const QDomDocument &xml_document,
const QString &file_path,
QString *error_message = nullptr);
bool writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message = nullptr);
QDomElement textToDomElement (QDomDocument &document,
const QString& tag_name,
const QString& value);
QDomElement textToDomElement (QDomDocument &document, const QString& tag_name, const QString& value);
QVector <QDomElement> directChild(const QDomElement &element,
const QString &tag_name);
QVector <QDomElement> subChild(const QDomElement &element,
const QString parent_tag_name,
const QString &children_tag_name);
QVector <QDomElement> directChild(const QDomElement &element, const QString &tag_name);
QVector <QDomElement> subChild(const QDomElement &element, const QString parent_tag_name, const QString &children_tag_name);
QDomElement marginsToXml (QDomDocument &parent_document,
const QMargins &margins);
QDomElement marginsToXml (QDomDocument &parent_document, const QMargins &margins);
QMargins marginsFromXml(const QDomElement &element);
QDomElement modelHeaderDataToXml(QDomDocument &parent_document,
const QAbstractItemModel *model,
QHash<int,
QList<int>> horizontal_section_role,
QHash<int,
QList<int>> vertical_section_role);
void modelHeaderDataFromXml(const QDomElement &element,
QAbstractItemModel *model);
QDomElement modelHeaderDataToXml(QDomDocument &parent_document, const QAbstractItemModel *model, QHash<int, QList<int>> horizontal_section_role, QHash<int, QList<int>> vertical_section_role);
void modelHeaderDataFromXml(const QDomElement &element, QAbstractItemModel *model);
}
#endif // QETXML_H

View File

@@ -739,7 +739,6 @@ QString RichTextEditor::text(Qt::TextFormat format) const
break;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#else
#pragma message("@TODO remove code for QT 5.14 or later")
case Qt::MarkdownText: //This enum value was added in Qt 5.14.
break;
#endif

View File

@@ -338,7 +338,6 @@ void TitleBlockTemplate::parseRows(const QString &rows_string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList rows_descriptions = rows_string.split(QChar(';'), QString::SkipEmptyParts);
#else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList rows_descriptions = rows_string.split(QChar(';'), Qt::SkipEmptyParts);
#endif
foreach (QString rows_description, rows_descriptions) {
@@ -366,7 +365,6 @@ void TitleBlockTemplate::parseColumns(const QString &cols_string) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList cols_descriptions = cols_string.split(QChar(';'), QString::SkipEmptyParts);
#else
#pragma message("@TODO remove code for QT 5.14 or later")
QStringList cols_descriptions = cols_string.split(QChar(';'), Qt::SkipEmptyParts);
#endif
foreach (QString cols_description, cols_descriptions) {

View File

@@ -21,13 +21,7 @@
#include <QThread>
#include <QDate>
#include <QScreen>
#include <QProcess>
/**
@brief AboutQETDialog::AboutQETDialog
@param parent
*/
AboutQETDialog::AboutQETDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutQETDialog)
@@ -42,17 +36,11 @@ AboutQETDialog::AboutQETDialog(QWidget *parent) :
setLicence();
}
/**
@brief AboutQETDialog::~AboutQETDialog
*/
AboutQETDialog::~AboutQETDialog()
{
delete ui;
}
/**
@brief AboutQETDialog::setAbout
*/
void AboutQETDialog::setAbout()
{
@@ -67,9 +55,6 @@ void AboutQETDialog::setAbout()
ui->m_about_label->setText(str);
}
/**
@brief AboutQETDialog::setAuthors
*/
void AboutQETDialog::setAuthors()
{
addAuthor(ui->m_author_label, "Benoît Ansieau", "benoit@qelectrotech.org", tr("Idée originale"));
@@ -81,9 +66,6 @@ void AboutQETDialog::setAuthors()
addAuthor(ui->m_author_label, "Abhishek Bansal", "abhishek@qelectrotech.org", tr("Développement"));
}
/**
@brief AboutQETDialog::setTranslators
*/
void AboutQETDialog::setTranslators()
{
addAuthor(ui->m_translators_label, "Alfredo Carreto", "electronicos_mx@yahoo.com.mx", tr("Traduction en espagnol"));
@@ -112,9 +94,6 @@ void AboutQETDialog::setTranslators()
addAuthor(ui->m_translators_label, "Gábor Gubányi", "gubanyig@gmail.com", tr("Traduction en hongrois"));
}
/**
@brief AboutQETDialog::setContributors
*/
void AboutQETDialog::setContributors()
{
addAuthor(ui->m_contrib_label, "Remi Collet", "remi@fedoraproject.org", tr("Paquets Fedora et Red Hat"));
@@ -138,9 +117,6 @@ void AboutQETDialog::setContributors()
addAuthor(ui->m_contrib_label, "Maximilian Federle", "", tr("Paquets Snap"));
}
/**
@brief AboutQETDialog::setVersion
*/
void AboutQETDialog::setVersion()
{
QString str = "<span style=\"font-weight:bold;font-size:16pt;\">QElectroTech V " + QET::displayedVersion + "</span>";
@@ -153,12 +129,6 @@ void AboutQETDialog::setVersion()
compilation_info += " : " + QString(__TIME__);
compilation_info += " <br>Run with Qt "+ QString(qVersion());
compilation_info += " using" + QString(" %1 thread(s)").arg(QThread::idealThreadCount());
QProcess macoscpuinfo;
macoscpuinfo.start("bash", QStringList() << "-c" << "sysctl -n machdep.cpu.brand_string");
macoscpuinfo.waitForFinished();
QString macosOutput = macoscpuinfo.readAllStandardOutput();
compilation_info += "<br>"" CPU : " + QString(macosOutput.toLocal8Bit().constData());
compilation_info += "<br>" " OS : " + QString(QSysInfo::kernelType());
compilation_info += " - " + QString(QSysInfo::currentCpuArchitecture());
compilation_info += " - Version : " + QString(QSysInfo::prettyProductName());
@@ -170,61 +140,15 @@ void AboutQETDialog::setVersion()
compilation_info += " : " + QString(__TIME__);
compilation_info += " <br>Run with Qt "+ QString(qVersion());
compilation_info += " using" + QString(" %1 thread(s)").arg(QThread::idealThreadCount());
QString OSName = QSysInfo::kernelType();
if (OSName == "linux")
{
QProcess linuxcpuinfo;
linuxcpuinfo.start("bash", QStringList() << "-c" << "cat /proc/cpuinfo |grep 'model name' | uniq");
linuxcpuinfo.waitForFinished();
QString linuxOutput = linuxcpuinfo.readAllStandardOutput();
compilation_info += "<br>"" CPU : " + QString(linuxOutput.toLocal8Bit().constData());
QProcess p;
p.start("awk", QStringList() << "/MemTotal/ { print $2 }" << "/proc/meminfo");
p.waitForFinished();
QString memory = p.readAllStandardOutput();
compilation_info += "<br>" + QString("RAM Total : %1 MB").arg(memory.toLong() / 1024);
p.close();
QProcess qp;
qp.start("awk", QStringList() << "/MemAvailable/ {print $2}" << "/proc/meminfo");
qp.waitForFinished();
QString AvailableMemory = qp.readAllStandardOutput();
compilation_info += "<br>" + QString("RAM Available : %1 MB").arg(AvailableMemory.toLong() / 1024);
qp.close();
QProcess linuxgpuinfo;
linuxgpuinfo.start("bash", QStringList() << "-c" << "lspci | grep VGA | cut -d : -f 3");
linuxgpuinfo.waitForFinished();
QString linuxGPUOutput = linuxgpuinfo.readAllStandardOutput();
compilation_info += "<br>"" GPU : " + QString(linuxGPUOutput.toLocal8Bit().constData());
}
compilation_info += "<br>" " OS : " + QString(QSysInfo::kernelType());
compilation_info += " - " + QString(QSysInfo::currentCpuArchitecture());
compilation_info += " - Version : " + QString(QSysInfo::prettyProductName());
compilation_info += "</br>" " - Kernel : " + QString(QSysInfo::kernelVersion());
#endif
#endif
compilation_info += "<br> *** Qt screens *** </br>";
const auto screens = qApp->screens();
for (int ii = 0; ii < screens.count(); ++ii) {
compilation_info += "<br> ( "
+ QString::number(ii + 1)
+ " : "
+ QString::number(screens[ii]->geometry().width() * screens[ii]->devicePixelRatio())
+ " x "
+ QString::number(screens[ii]->geometry().height() * screens[ii]->devicePixelRatio())
+ " ) </br>";
}
ui->m_version_label->setText(str + compilation_info);
}
/**
@brief AboutQETDialog::setLibraries
*/
void AboutQETDialog::setLibraries()
{
addLibrary(ui->m_libraries_label, "KDE lib", "https://api.kde.org");
@@ -232,22 +156,19 @@ void AboutQETDialog::setLibraries()
addLibrary(ui->m_libraries_label, "pugixml", "https://pugixml.org");
}
/**
@brief AboutQETDialog::setLicence
*/
void AboutQETDialog::setLicence()
{
ui->m_license_text_edit->setPlainText(QET::license());
}
/**
@brief AboutQETDialog::addAuthor
Adds a person to the list of authors
@param label : QLabel which will add the person
@param name : Name of person
@param email : E-mail address of the person
@param work : Function / work done by the person
*/
* @brief AboutQETDialog::addAuthor
* Adds a person to the list of authors
* @param label : QLabel which will add the person
* @param name : Name of person
* @param email : E-mail address of the person
* @param work : Function / work done by the person
*/
void AboutQETDialog::addAuthor(QLabel *label, const QString &name, const QString &email, const QString &work)
{
QString new_text = label->text();
@@ -259,12 +180,6 @@ void AboutQETDialog::addAuthor(QLabel *label, const QString &name, const QString
label->setText(new_text);
}
/**
@brief AboutQETDialog::addLibrary
@param label
@param name
@param link
*/
void AboutQETDialog::addLibrary(QLabel *label, const QString &name, const QString &link)
{
QString new_text = label->text();

View File

@@ -26,9 +26,6 @@ namespace Ui {
class AboutQETDialog;
}
/**
@brief The AboutQETDialog class
*/
class AboutQETDialog : public QDialog
{
Q_OBJECT
@@ -45,13 +42,8 @@ class AboutQETDialog : public QDialog
void setVersion();
void setLibraries();
void setLicence();
void addAuthor(QLabel *label,
const QString &name,
const QString &email,
const QString &work);
void addLibrary(QLabel *label,
const QString &name,
const QString &link);
void addAuthor(QLabel *label, const QString &name, const QString &email, const QString &work);
void addLibrary(QLabel *label, const QString &name, const QString &link);
private:
Ui::AboutQETDialog *ui;

View File

@@ -61,7 +61,6 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) :
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](int id)
#else
#pragma message("@TODO remove code for QT 5.15 or later")
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id)
#endif
{
@@ -155,7 +154,6 @@ int BOMExportDialog::exec()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << getBom() << endl;
#else
#pragma message("@TODO remove code for QT 5.15 or later")
stream << getBom() << &Qt::endl(stream);
#endif
}

View File

@@ -16,7 +16,6 @@ CompositeTextEditDialog::CompositeTextEditDialog(DynamicElementTextItem *text, Q
m_default_text = m_text->compositeText();
ui->m_plain_text_edit->setPlainText(m_default_text);
#if QT_VERSION >= 0x050300
#pragma message("@TODO remove code for QT 5.3 or later")
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
#endif
setUpComboBox();
@@ -30,7 +29,6 @@ CompositeTextEditDialog::CompositeTextEditDialog(QString text, QWidget *parent)
m_default_text = std::move(text);
ui->m_plain_text_edit->setPlainText(m_default_text);
#if QT_VERSION >= 0x050300
#pragma message("@TODO remove code for QT 5.3 or later")
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
#endif
setUpComboBox();

View File

@@ -25,11 +25,11 @@
#include <linkelementcommand.h>
/**
@brief MasterPropertiesWidget::MasterPropertiesWidget
Default constructor
@param elmt
@param parent
*/
* @brief MasterPropertiesWidget::MasterPropertiesWidget
* Default constructor
* @param elmt
* @param parent
*/
MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
AbstractElementPropertiesEditorWidget(parent),
ui(new Ui::MasterPropertiesWidget),
@@ -43,16 +43,10 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
QStringList list;
QSettings settings;
if (settings.value("genericpanel/folio", false).toBool()) {
list << tr("Vignette")
<< tr("Label de folio")
<< tr("Titre de folio")
<< tr("Position");
list << tr("Vignette") << tr("Label de folio") << tr("Titre de folio") << tr("Position");
}
else {
list << tr("Vignette")
<< tr("N° de folio")
<< tr("Titre de folio")
<< tr("Position");
list << tr("Vignette") << tr("N° de folio") << tr("Titre de folio") << tr("Position");
}
ui->m_free_tree_widget->setHeaderLabels(list);
ui->m_link_tree_widget->setHeaderLabels(list);
@@ -64,22 +58,15 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
m_show_element = new QAction(tr("Montrer l'élément maître"), this);
m_save_header_state = new QAction(tr("Enregistrer la disposition"), this);
connect(ui->m_free_tree_widget, &QTreeWidget::itemDoubleClicked,
this, &MasterPropertiesWidget::showElementFromTWI);
connect(ui->m_link_tree_widget, &QTreeWidget::itemDoubleClicked,
this, &MasterPropertiesWidget::showElementFromTWI);
connect(ui->m_free_tree_widget, &QTreeWidget::itemDoubleClicked, this, &MasterPropertiesWidget::showElementFromTWI);
connect(ui->m_link_tree_widget, &QTreeWidget::itemDoubleClicked, this, &MasterPropertiesWidget::showElementFromTWI);
connect(ui->m_free_tree_widget, &QTreeWidget::customContextMenuRequested,
[this](QPoint point) {this->customContextMenu(point, 1);});
connect(ui->m_link_tree_widget, &QTreeWidget::customContextMenuRequested,
[this](QPoint point) {this->customContextMenu(point, 2);});
connect(ui->m_free_tree_widget, &QTreeWidget::customContextMenuRequested, [this](QPoint point) {this->customContextMenu(point, 1);});
connect(ui->m_link_tree_widget, &QTreeWidget::customContextMenuRequested, [this](QPoint point) {this->customContextMenu(point, 2);});
connect(m_link_action, &QAction::triggered,
this, &MasterPropertiesWidget::on_link_button_clicked);
connect(m_unlink_action, &QAction::triggered,
this, &MasterPropertiesWidget::on_unlink_button_clicked);
connect(m_show_qtwi, &QAction::triggered,
[this]() {this->showElementFromTWI(this->m_qtwi_at_context_menu,0);});
connect(m_link_action, &QAction::triggered, this, &MasterPropertiesWidget::on_link_button_clicked);
connect(m_unlink_action, &QAction::triggered, this, &MasterPropertiesWidget::on_unlink_button_clicked);
connect(m_show_qtwi, &QAction::triggered, [this]() {this->showElementFromTWI(this->m_qtwi_at_context_menu,0);});
connect(m_show_element, &QAction::triggered, [this]()
{
@@ -91,8 +78,7 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
QHeaderView *qhv = ui->m_free_tree_widget->header();
qhv->setContextMenuPolicy(Qt::CustomContextMenu);
connect(qhv, &QHeaderView::customContextMenuRequested,
this, &MasterPropertiesWidget::headerCustomContextMenuRequested);
connect(qhv, &QHeaderView::customContextMenuRequested, this, &MasterPropertiesWidget::headerCustomContextMenuRequested);
connect(m_save_header_state, &QAction::triggered, [qhv]()
{
QByteArray qba = qhv->saveState();
@@ -104,9 +90,9 @@ MasterPropertiesWidget::MasterPropertiesWidget(Element *elmt, QWidget *parent) :
}
/**
@brief MasterPropertiesWidget::~MasterPropertiesWidget
Destructor
*/
* @brief MasterPropertiesWidget::~MasterPropertiesWidget
* Destructor
*/
MasterPropertiesWidget::~MasterPropertiesWidget()
{
if (m_showed_element)
@@ -119,10 +105,10 @@ MasterPropertiesWidget::~MasterPropertiesWidget()
}
/**
@brief MasterPropertiesWidget::setElement
Set the element to be edited
@param element
*/
* @brief MasterPropertiesWidget::setElement
* Set the element to be edited
* @param element
*/
void MasterPropertiesWidget::setElement(Element *element)
{
if (m_element == element)
@@ -137,37 +123,32 @@ void MasterPropertiesWidget::setElement(Element *element)
m_element->setHighlighted(false);
if (m_project)
disconnect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)),
this, SLOT(diagramWasdeletedFromProject()));
disconnect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(diagramWasdeletedFromProject()));
if(Q_LIKELY(element->diagram() && element->diagram()->project()))
{
m_project = element->diagram()->project();
connect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)),
this, SLOT(diagramWasdeletedFromProject()));
connect(m_project, SIGNAL(diagramRemoved(QETProject*,Diagram*)), this, SLOT(diagramWasdeletedFromProject()));
}
else
m_project = nullptr;
//Keep up to date this widget when the linked elements of m_element change
//Keep up to date this widget when the linked elements of m_element change
if (m_element)
disconnect(m_element.data(), &Element::linkedElementChanged,
this, &MasterPropertiesWidget::updateUi);
disconnect(m_element.data(), &Element::linkedElementChanged, this, &MasterPropertiesWidget::updateUi);
m_element = element;
connect(m_element.data(), &Element::linkedElementChanged,
this, &MasterPropertiesWidget::updateUi);
connect(m_element.data(), &Element::linkedElementChanged, this, &MasterPropertiesWidget::updateUi);
updateUi();
}
/**
@brief MasterPropertiesWidget::apply
If link betwen edited element and other change,
apply the change with a QUndoCommand (got with method associatedUndo)
pushed to the stack of element project.
Return true if link change, else false
@note is void no Return ???
* @brief MasterPropertiesWidget::apply
* If link betwen edited element and other change,
* apply the change with a QUndoCommand (got with method associatedUndo)
* pushed to the stack of element project.
* Return true if link change, else false
*/
void MasterPropertiesWidget::apply() {
if (QUndoCommand *undo = associatedUndo())
@@ -175,9 +156,9 @@ void MasterPropertiesWidget::apply() {
}
/**
@brief MasterPropertiesWidget::reset
Reset curent widget, clear eveything and rebuild widget.
*/
* @brief MasterPropertiesWidget::reset
* Reset curent widget, clear eveything and rebuild widget.
*/
void MasterPropertiesWidget::reset()
{
foreach (QTreeWidgetItem *qtwi, m_qtwi_hash.keys())
@@ -188,12 +169,12 @@ void MasterPropertiesWidget::reset()
}
/**
@brief MasterPropertiesWidget::associatedUndo
If link between the edited element and other change,
return a QUndoCommand with this change.
If no change return nullptr.
@return
*/
* @brief MasterPropertiesWidget::associatedUndo
* If link between the edited element and other change,
* return a QUndoCommand with this change.
* If no change return nullptr.
* @return
*/
QUndoCommand* MasterPropertiesWidget::associatedUndo() const
{
QList <Element *> to_link;
@@ -226,11 +207,11 @@ QUndoCommand* MasterPropertiesWidget::associatedUndo() const
}
/**
@brief MasterPropertiesWidget::setLiveEdit
@param live_edit = true : live edit is enable
else false : live edit is disable.
@return always true because live edit is handled by this editor widget
*/
* @brief MasterPropertiesWidget::setLiveEdit
* @param live_edit = true : live edit is enable
* else false : live edit is disable.
* @return always true because live edit is handled by this editor widget
*/
bool MasterPropertiesWidget::setLiveEdit(bool live_edit)
{
m_live_edit = live_edit;
@@ -238,9 +219,9 @@ bool MasterPropertiesWidget::setLiveEdit(bool live_edit)
}
/**
@brief MasterPropertiesWidget::updateUi
Build the interface of the widget
*/
* @brief MasterPropertiesWidget::updateUi
* Build the interface of the widget
*/
void MasterPropertiesWidget::updateUi()
{
ui->m_free_tree_widget->clear();
@@ -264,24 +245,17 @@ void MasterPropertiesWidget::updateUi()
if(settings.value("genericpanel/folio", false).toBool())
{
autonum::sequentialNumbers seq;
QString F =autonum::AssignVariables::formulaToLabel(
elmt->diagram()->border_and_titleblock.folio(),
seq,
elmt->diagram(),
elmt);
QString F =autonum::AssignVariables::formulaToLabel(elmt->diagram()->border_and_titleblock.folio(), seq, elmt->diagram(), elmt);
qtwi->setText(1, F);
}
else
{
qtwi->setText(1, QString::number(
elmt->diagram()->folioIndex()
+ 1));
qtwi->setText(1, QString::number(elmt->diagram()->folioIndex() + 1));
}
qtwi->setText(2, elmt->diagram()->title());
qtwi->setText(4, elmt->diagram()->convertPosition(
elmt->scenePos()).toString());
qtwi->setText(4, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
items_list.append(qtwi);
m_qtwi_hash.insert(qtwi, elmt);
}
@@ -299,23 +273,16 @@ void MasterPropertiesWidget::updateUi()
if(settings.value("genericpanel/folio", false).toBool())
{
autonum::sequentialNumbers seq;
QString F =autonum::AssignVariables::formulaToLabel(
elmt->diagram()->border_and_titleblock.folio(),
seq,
elmt->diagram(),
elmt);
QString F =autonum::AssignVariables::formulaToLabel(elmt->diagram()->border_and_titleblock.folio(), seq, elmt->diagram(), elmt);
qtwi->setText(1, F);
}
else
{
qtwi->setText(1, QString::number(
elmt->diagram()->folioIndex()
+ 1));
qtwi->setText(1, QString::number(elmt->diagram()->folioIndex() + 1));
}
qtwi->setText(2, elmt->diagram()->title());
qtwi->setText(3, elmt->diagram()->convertPosition(
elmt->scenePos()).toString());
qtwi->setText(3, elmt->diagram()->convertPosition(elmt->scenePos()).toString());
items_list.append(qtwi);
m_qtwi_hash.insert(qtwi, elmt);
}
@@ -331,10 +298,6 @@ void MasterPropertiesWidget::updateUi()
}
}
/**
@brief MasterPropertiesWidget::headerCustomContextMenuRequested
@param pos
*/
void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
{
m_context_menu->clear();
@@ -343,17 +306,16 @@ void MasterPropertiesWidget::headerCustomContextMenuRequested(const QPoint &pos)
}
/**
@brief MasterPropertiesWidget::on_link_button_clicked
move curent item in the free_list to linked_list
*/
* @brief MasterPropertiesWidget::on_link_button_clicked
* move curent item in the free_list to linked_list
*/
void MasterPropertiesWidget::on_link_button_clicked()
{
//take the curent item from free_list and push it to linked_list
QTreeWidgetItem *qtwi = ui->m_free_tree_widget->currentItem();
if (qtwi)
{
ui->m_free_tree_widget->takeTopLevelItem(
ui->m_free_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_free_tree_widget->takeTopLevelItem(ui->m_free_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_link_tree_widget->insertTopLevelItem(0, qtwi);
if(m_live_edit)
@@ -362,17 +324,16 @@ void MasterPropertiesWidget::on_link_button_clicked()
}
/**
@brief MasterPropertiesWidget::on_unlink_button_clicked
move curent item in linked_list to free_list
*/
* @brief MasterPropertiesWidget::on_unlink_button_clicked
* move curent item in linked_list to free_list
*/
void MasterPropertiesWidget::on_unlink_button_clicked()
{
//take the curent item from linked_list and push it to free_list
QTreeWidgetItem *qtwi = ui->m_link_tree_widget->currentItem();
if(qtwi)
{
ui->m_link_tree_widget->takeTopLevelItem(
ui->m_link_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_link_tree_widget->takeTopLevelItem(ui->m_link_tree_widget->indexOfTopLevelItem(qtwi));
ui->m_free_tree_widget->insertTopLevelItem(0, qtwi);
if(m_live_edit)
@@ -381,18 +342,17 @@ void MasterPropertiesWidget::on_unlink_button_clicked()
}
/**
@brief MasterPropertiesWidget::showElementFromTWI
Show the element corresponding to the given QTreeWidgetItem
@param qtwi
@param column
*/
* @brief MasterPropertiesWidget::showElementFromTWI
* Show the element corresponding to the given QTreeWidgetItem
* @param qtwi
* @param column
*/
void MasterPropertiesWidget::showElementFromTWI(QTreeWidgetItem *qtwi, int column)
{
Q_UNUSED(column);
if (m_showed_element)
{
disconnect(m_showed_element, SIGNAL(destroyed()),
this, SLOT(showedElementWasDeleted()));
disconnect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
m_showed_element -> setHighlighted(false);
}
if (m_element)
@@ -401,44 +361,39 @@ void MasterPropertiesWidget::showElementFromTWI(QTreeWidgetItem *qtwi, int colum
m_showed_element = m_qtwi_hash[qtwi];
m_showed_element->diagram()->showMe();
m_showed_element->setHighlighted(true);
connect(m_showed_element, SIGNAL(destroyed()),
this, SLOT(showedElementWasDeleted()));
connect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted()));
}
/**
@brief MasterPropertiesWidget::showedElementWasDeleted
Set to nullptr the current showed element when he was deleted
*/
* @brief MasterPropertiesWidget::showedElementWasDeleted
* Set to nullptr the current showed element when he was deleted
*/
void MasterPropertiesWidget::showedElementWasDeleted() {
m_showed_element = nullptr;
}
/**
@brief MasterPropertiesWidget::diagramWasdeletedFromProject
This slot is called when a diagram is removed from the parent project
of edited element to update the content of this widget
*/
* @brief MasterPropertiesWidget::diagramWasdeletedFromProject
* This slot is called when a diagram is removed from the parent project of edited element
* to update the content of this widget
*/
void MasterPropertiesWidget::diagramWasdeletedFromProject()
{
// We use a timer because if the removed diagram
// contain slave element linked to the edited element
// we must to wait for this elements be unlinked,
// else the linked list provide deleted elements.
//We use a timer because if the removed diagram contain slave element linked to the edited element
//we must to wait for this elements be unlinked, else the linked list provide deleted elements.
QTimer::singleShot(10, this, SLOT(updateUi()));
}
/**
@brief MasterPropertiesWidget::customContextMenu
Display a context menu
@param pos
@param i : the tree widget where the context menu was requested.
*/
* @brief MasterPropertiesWidget::customContextMenu
* Display a context menu
* @param pos
* @param i : the tree widget where the context menu was requested.
*/
void MasterPropertiesWidget::customContextMenu(const QPoint &pos, int i)
{
// add the size of the header to display the topleft of the QMenu
// at the position of the mouse.
// See doc about QWidget::customContextMenuRequested
// section related to QAbstractScrollArea
//add the size of the header to display the topleft of the QMenu at the position of the mouse.
//See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea
QPoint point = pos;
point.ry()+=ui->m_free_tree_widget->header()->height();

View File

@@ -35,30 +35,24 @@ namespace Ui {
}
/**
@brief The MasterPropertiesWidget class
This class is a widget for make link between a master element
with several slave element.
This class embenddedthe undo/redo command when apply new connection.
*/
* @brief The MasterPropertiesWidget class
* This class is a widget for make link between a master element with several slave element.
* This class embenddedthe undo/redo command when apply new connection.
*/
class MasterPropertiesWidget : public AbstractElementPropertiesEditorWidget
{
Q_OBJECT
public:
explicit MasterPropertiesWidget(Element *elmt,
QWidget *parent = nullptr);
explicit MasterPropertiesWidget(Element *elmt, QWidget *parent = nullptr);
~MasterPropertiesWidget() override;
void setElement (Element *element) override;
void apply() override;
void reset() override;
QUndoCommand *associatedUndo () const override;
/**
* @brief title
* @return QString title
*/
QString title() const override {
return tr("Référence croisée (maître)");}
QString title() const override {return tr("Référence croisée (maître)");}
bool setLiveEdit(bool live_edit) override;
public slots:

View File

@@ -77,7 +77,6 @@ m_diagram(diagram)
#if QT_VERSION >= 0x050900
else
setObsolete(true);
#pragma message("@TODO remove code for QT 5.9 or later")
#endif
}
@@ -136,7 +135,6 @@ void RotateTextsCommand::openDialog()
#if QT_VERSION >= 0x050900
else
setObsolete(true);
#pragma message("@TODO remove code for QT 5.9 or later")
#endif
}