mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Wrap code for better readability
This commit is contained in:
@@ -376,7 +376,10 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
|
||||
if (!element_file.exists())
|
||||
return QString();
|
||||
|
||||
created_child = QETXML::fileSystemElementToXmlCollectionElement(m_dom_document, element_file);
|
||||
created_child = QETXML::
|
||||
fileSystemElementToXmlCollectionElement(
|
||||
m_dom_document,
|
||||
element_file);
|
||||
}
|
||||
|
||||
//str is the path of a directory, we integrate a directory.
|
||||
@@ -385,7 +388,10 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
|
||||
if (!dir.cd(str))
|
||||
return QString();
|
||||
|
||||
created_child = QETXML::fileSystemDirToXmlCollectionDir(m_dom_document, dir);
|
||||
created_child = QETXML::
|
||||
fileSystemDirToXmlCollectionDir(
|
||||
m_dom_document,
|
||||
dir);
|
||||
}
|
||||
|
||||
if(created_child.isNull())
|
||||
|
||||
@@ -36,35 +36,56 @@ class XmlElementCollection : public QObject
|
||||
|
||||
public:
|
||||
XmlElementCollection (QETProject *project);
|
||||
XmlElementCollection (const QDomElement &dom_element, QETProject *project);
|
||||
XmlElementCollection (const QDomElement &dom_element,
|
||||
QETProject *project);
|
||||
QDomElement root() const;
|
||||
QDomElement importCategory() const;
|
||||
QDomNodeList childs(const QDomElement &parent_element) const;
|
||||
QDomElement child(const QDomElement &parent_element, const QString &child_name) const;
|
||||
QDomElement child(const QDomElement &parent_element,
|
||||
const QString &child_name) const;
|
||||
QDomElement child(const QString &path) const;
|
||||
QList<QDomElement> directories(const QDomElement &parent_element) const;
|
||||
QStringList directoriesNames(const QDomElement &parent_element) const;
|
||||
QList<QDomElement> elements(const QDomElement &parent_element) const;
|
||||
QStringList elementsNames(const QDomElement &parent_element) const;
|
||||
QList<QDomElement> directories(
|
||||
const QDomElement &parent_element) const;
|
||||
QStringList directoriesNames(
|
||||
const QDomElement &parent_element) const;
|
||||
QList<QDomElement> elements(
|
||||
const QDomElement &parent_element) const;
|
||||
QStringList elementsNames(
|
||||
const QDomElement &parent_element) const;
|
||||
QDomElement element(const QString &path) const;
|
||||
QDomElement directory(const QString &path) const;
|
||||
QString addElement (ElementsLocation &location);
|
||||
bool addElementDefinition (const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition);
|
||||
bool addElementDefinition (const QString &dir_path,
|
||||
const QString &elmt_name,
|
||||
const QDomElement &xml_definition);
|
||||
bool removeElement(const QString& path);
|
||||
ElementsLocation copy (ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString(), bool deep_copy = true);
|
||||
ElementsLocation copy (ElementsLocation &source,
|
||||
ElementsLocation &destination,
|
||||
const QString& rename = QString(),
|
||||
bool deep_copy = true);
|
||||
bool exist (const QString &path) const;
|
||||
bool createDir (const QString& path, const QString& name, const NamesList &name_list);
|
||||
bool createDir (const QString& path,
|
||||
const QString& name,
|
||||
const NamesList &name_list);
|
||||
bool removeDir (const QString& path);
|
||||
|
||||
QList <ElementsLocation> elementsLocation (QDomElement dom_element = QDomElement(), bool childs = true) const;
|
||||
QList <ElementsLocation> elementsLocation (
|
||||
QDomElement dom_element = QDomElement(),
|
||||
bool childs = true) const;
|
||||
ElementsLocation domToLocation(QDomElement dom_element) const;
|
||||
|
||||
void cleanUnusedElement();
|
||||
void cleanUnusedDirectory();
|
||||
|
||||
private:
|
||||
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString(), bool deep_copy = true);
|
||||
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString());
|
||||
ElementsLocation copyDirectory(
|
||||
ElementsLocation &source,
|
||||
ElementsLocation &destination,
|
||||
const QString& rename = QString(),
|
||||
bool deep_copy = true);
|
||||
ElementsLocation copyElement(ElementsLocation &source,
|
||||
ElementsLocation &destination,
|
||||
const QString& rename = QString());
|
||||
|
||||
signals:
|
||||
/**
|
||||
|
||||
@@ -170,8 +170,11 @@ QETProject *XmlProjectElementCollectionItem::project() const
|
||||
Use this method for set this item the root of the collection
|
||||
@param project : project to manage the collection
|
||||
@param set_data : if true, call setUpData for every child of this item
|
||||
@param hide_element : bool
|
||||
*/
|
||||
void XmlProjectElementCollectionItem::setProject(QETProject *project, bool set_data, bool hide_element)
|
||||
void XmlProjectElementCollectionItem::setProject(QETProject *project,
|
||||
bool set_data,
|
||||
bool hide_element)
|
||||
{
|
||||
if (m_project)
|
||||
return;
|
||||
@@ -271,11 +274,16 @@ void XmlProjectElementCollectionItem::populate(bool set_data, bool hide_element)
|
||||
/**
|
||||
@brief XmlProjectElementCollectionItem::setXmlElement
|
||||
Set the managed content of this item
|
||||
@param element : the dom element (directory or element), to be managed by this item
|
||||
@param element :
|
||||
the dom element (directory or element), to be managed by this item
|
||||
@param project : the parent project of managed collection
|
||||
@param set_data : if true, call setUpData for every child of this item
|
||||
@param hide_element : bool
|
||||
*/
|
||||
void XmlProjectElementCollectionItem::setXmlElement(const QDomElement& element, QETProject *project, bool set_data, bool hide_element)
|
||||
void XmlProjectElementCollectionItem::setXmlElement(const QDomElement& element,
|
||||
QETProject *project,
|
||||
bool set_data,
|
||||
bool hide_element)
|
||||
{
|
||||
m_dom_element = element;
|
||||
m_project = project;
|
||||
|
||||
@@ -46,13 +46,18 @@ class XmlProjectElementCollectionItem : public ElementCollectionItem
|
||||
void addChildAtPath(const QString &collection_name) override;
|
||||
QETProject * project() const;
|
||||
|
||||
void setProject (QETProject *project, bool set_data = true, bool hide_element = false);
|
||||
void setProject (QETProject *project,
|
||||
bool set_data = true,
|
||||
bool hide_element = false);
|
||||
void setUpData() override;
|
||||
void setUpIcon() override;
|
||||
|
||||
private:
|
||||
void populate(bool set_data = true, bool hide_element = false);
|
||||
void setXmlElement(const QDomElement& element, QETProject *project, bool set_data = true, bool hide_element = false);
|
||||
void setXmlElement(const QDomElement& element,
|
||||
QETProject *project,
|
||||
bool set_data = true,
|
||||
bool hide_element = false);
|
||||
|
||||
private:
|
||||
QETProject *m_project = nullptr;
|
||||
|
||||
@@ -116,7 +116,8 @@ void SelectAutonumW::setContext(const NumerotationContext &context) {
|
||||
*/
|
||||
NumerotationContext SelectAutonumW::toNumContext() const {
|
||||
NumerotationContext nc;
|
||||
foreach (NumPartEditorW *npew, num_part_list_) nc << npew -> toNumContext();
|
||||
foreach (NumPartEditorW *npew, num_part_list_)
|
||||
nc << npew -> toNumContext();
|
||||
return nc;
|
||||
}
|
||||
|
||||
@@ -187,44 +188,50 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
|
||||
case QDialogButtonBox::HelpRole:
|
||||
if (m_edited_type == 2)
|
||||
{
|
||||
QMessageBox::information (this, tr("Folio Autonumérotation", "title window"),
|
||||
tr("C'est ici que vous pouvez définir la manière dont seront numérotés les nouveaux folios.\n"
|
||||
"-Une numérotation est composée d'une variable minimum.\n"
|
||||
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
|
||||
"-Une variable de numérotation comprend : un type, une valeur et une incrémentation.\n"
|
||||
QMessageBox::information (
|
||||
this,
|
||||
tr("Folio Autonumérotation",
|
||||
"title window"),
|
||||
tr("C'est ici que vous pouvez définir la manière dont seront numérotés les nouveaux folios.\n"
|
||||
"-Une numérotation est composée d'une variable minimum.\n"
|
||||
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
|
||||
"-Une variable de numérotation comprend : un type, une valeur et une incrémentation.\n"
|
||||
|
||||
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représentent un type numérique défini dans le champ \"Valeur\", "
|
||||
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
|
||||
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représentés sur le schéma par deux et trois digits minimum.\n"
|
||||
"Si le chiffre défini dans le champ Valeur possède moins de digits que le type choisi,"
|
||||
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
|
||||
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représentent un type numérique défini dans le champ \"Valeur\", "
|
||||
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
|
||||
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représentés sur le schéma par deux et trois digits minimum.\n"
|
||||
"Si le chiffre défini dans le champ Valeur possède moins de digits que le type choisi,"
|
||||
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
|
||||
|
||||
"\n-Le type \"Texte\", représente un texte fixe.\nLe champ \"Incrémentation\" n'est pas utilisé.\n",
|
||||
"help dialog about the folio autonumerotation"
|
||||
));
|
||||
"\n-Le type \"Texte\", représente un texte fixe.\nLe champ \"Incrémentation\" n'est pas utilisé.\n",
|
||||
"help dialog about the folio autonumerotation"
|
||||
));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::information (this, tr("Conducteur Autonumérotation", "title window"),
|
||||
tr("C'est ici que vous pouvez définir la manière dont seront numérotés les nouveaux conducteurs.\n"
|
||||
"-Une numérotation est composée d'une variable minimum.\n"
|
||||
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
|
||||
"-Une variable de numérotation comprend : un type, une valeur et une incrémentation.\n"
|
||||
QMessageBox::information (
|
||||
this,
|
||||
tr("Conducteur Autonumérotation",
|
||||
"title window"),
|
||||
tr("C'est ici que vous pouvez définir la manière dont seront numérotés les nouveaux conducteurs.\n"
|
||||
"-Une numérotation est composée d'une variable minimum.\n"
|
||||
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
|
||||
"-Une variable de numérotation comprend : un type, une valeur et une incrémentation.\n"
|
||||
|
||||
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représentent un type numérique défini dans le champ \"Valeur\", "
|
||||
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
|
||||
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représentés sur le schéma par deux et trois digits minimum.\n"
|
||||
"Si le chiffre défini dans le champ Valeur possède moins de digits que le type choisi,"
|
||||
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
|
||||
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représentent un type numérique défini dans le champ \"Valeur\", "
|
||||
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
|
||||
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représentés sur le schéma par deux et trois digits minimum.\n"
|
||||
"Si le chiffre défini dans le champ Valeur possède moins de digits que le type choisi,"
|
||||
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
|
||||
|
||||
"\n-Le type \"Texte\", représente un texte fixe.\nLe champ \"Incrémentation\" n'est pas utilisé.\n"
|
||||
"\n-Le type \"Texte\", représente un texte fixe.\nLe champ \"Incrémentation\" n'est pas utilisé.\n"
|
||||
|
||||
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.\n"
|
||||
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.\n"
|
||||
|
||||
"\n-Le type \"Folio\" représente le nom du folio en cours.\nLes autres champs ne sont pas utilisés.",
|
||||
"help dialog about the conductor autonumerotation"
|
||||
));
|
||||
"\n-Le type \"Folio\" représente le nom du folio en cours.\nLes autres champs ne sont pas utilisés.",
|
||||
"help dialog about the conductor autonumerotation"
|
||||
));
|
||||
break;
|
||||
}
|
||||
//apply the context in the diagram displayed by @diagram_chooser.
|
||||
@@ -242,7 +249,10 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
|
||||
void SelectAutonumW::applyEnable(bool b) {
|
||||
if (b){
|
||||
bool valid= true;
|
||||
foreach (NumPartEditorW *npe, num_part_list_) if (!npe -> isValid()) valid= false;
|
||||
foreach (NumPartEditorW *npe, num_part_list_)
|
||||
if (!npe -> isValid())
|
||||
valid= false;
|
||||
|
||||
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -47,7 +47,9 @@ TerminalEditor::TerminalEditor(QETElementEditor* editor, QWidget* parent):
|
||||
@param parent :
|
||||
QWidget parent de ce widget
|
||||
*/
|
||||
TerminalEditor::TerminalEditor(QETElementEditor *editor, QList<PartTerminal *> &terms, QWidget *parent) :
|
||||
TerminalEditor::TerminalEditor(QETElementEditor *editor,
|
||||
QList<PartTerminal *> &terms,
|
||||
QWidget *parent) :
|
||||
ElementItemEditor(editor, parent),
|
||||
m_terminals(terms),
|
||||
m_part(terms.first()) {
|
||||
|
||||
@@ -35,7 +35,9 @@ class TerminalEditor : public ElementItemEditor {
|
||||
|
||||
// Constructors, destructor
|
||||
public:
|
||||
TerminalEditor(QETElementEditor *, QList<PartTerminal *>& terms, QWidget * = nullptr);
|
||||
TerminalEditor(QETElementEditor *,
|
||||
QList<PartTerminal *>& terms,
|
||||
QWidget * = nullptr);
|
||||
TerminalEditor(QETElementEditor *, QWidget * = nullptr);
|
||||
~TerminalEditor() override;
|
||||
private:
|
||||
|
||||
@@ -44,16 +44,16 @@
|
||||
@param parent : parent widget of the returned editor
|
||||
@return an editor or nullptr
|
||||
*/
|
||||
PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(QAbstractItemModel *model, PropertiesEditorWidget *editor, QWidget *parent)
|
||||
PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
|
||||
QAbstractItemModel *model,
|
||||
PropertiesEditorWidget *editor,
|
||||
QWidget *parent)
|
||||
{
|
||||
Q_UNUSED(model)
|
||||
Q_UNUSED(editor)
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if (auto m = static_cast<ProjectDBModel *>(model))
|
||||
{
|
||||
if (editor &&
|
||||
editor->metaObject()->className() == ProjectDBModelPropertiesWidget::staticMetaObject.className())
|
||||
editor->metaObject()->className()
|
||||
== ProjectDBModelPropertiesWidget::staticMetaObject.className())
|
||||
{
|
||||
static_cast<ProjectDBModelPropertiesWidget *>(editor)->setModel(m);
|
||||
return editor;
|
||||
@@ -72,7 +72,10 @@ PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(QAbstractItemM
|
||||
@param parent : parent widget of the returned editor
|
||||
@return : an editor or nullptr;
|
||||
*/
|
||||
PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(QList<QGraphicsItem *> items, PropertiesEditorWidget *editor, QWidget *parent)
|
||||
PropertiesEditorWidget *PropertiesEditorFactory::propertiesEditor(
|
||||
QList<QGraphicsItem *> items,
|
||||
PropertiesEditorWidget *editor,
|
||||
QWidget *parent)
|
||||
{
|
||||
int count_ = items.size();
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ XRefProperties::XRefProperties()
|
||||
@param settings: QSettings to use
|
||||
@param prefix: prefix before properties name
|
||||
*/
|
||||
void XRefProperties::toSettings(QSettings &settings, const QString prefix) const {
|
||||
void XRefProperties::toSettings(QSettings &settings,
|
||||
const QString prefix) const {
|
||||
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
||||
QString display = m_display == Cross? "cross" : "contacts";
|
||||
settings.setValue(prefix + "displayhas", display);
|
||||
@@ -69,7 +70,8 @@ void XRefProperties::toSettings(QSettings &settings, const QString prefix) const
|
||||
@param settings: QSettings to use
|
||||
@param prefix: prefix before properties name
|
||||
*/
|
||||
void XRefProperties::fromSettings(const QSettings &settings, const QString prefix)
|
||||
void XRefProperties::fromSettings(const QSettings &settings,
|
||||
const QString prefix)
|
||||
{
|
||||
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
||||
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
||||
|
||||
@@ -40,9 +40,11 @@ class XRefProperties : public PropertiesInterface
|
||||
Label
|
||||
};
|
||||
|
||||
void toSettings (QSettings &settings, const QString = QString()) const override;
|
||||
void fromSettings (const QSettings &settings, const QString = QString()) override;
|
||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||
void toSettings (QSettings &settings,
|
||||
const QString = QString()) const override;
|
||||
void fromSettings (const QSettings &settings,
|
||||
const QString = QString()) override;
|
||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
|
||||
static QHash<QString, XRefProperties> defaultProperties();
|
||||
|
||||
@@ -22,10 +22,11 @@
|
||||
@brief SimpleElement::SimpleElement
|
||||
@param location
|
||||
@param qgi
|
||||
@param s
|
||||
@param state
|
||||
*/
|
||||
SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||
SimpleElement::SimpleElement(const ElementsLocation &location,
|
||||
QGraphicsItem *qgi,
|
||||
int *state) :
|
||||
Element(location, qgi, state, Element::Simple)
|
||||
{}
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ class SimpleElement : public Element {
|
||||
Q_OBJECT
|
||||
|
||||
public :
|
||||
explicit SimpleElement(const ElementsLocation &, QGraphicsItem * = nullptr, int * = nullptr);
|
||||
explicit SimpleElement(const ElementsLocation &,
|
||||
QGraphicsItem * = nullptr,
|
||||
int * = nullptr);
|
||||
~SimpleElement() override;
|
||||
|
||||
void initLink(QETProject *project) override;
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
Default constructor
|
||||
@param location location of xml definition
|
||||
@param qgi parent QGraphicItem
|
||||
@param s parent diagram
|
||||
@param state int used to know if the creation of element have error
|
||||
*/
|
||||
SlaveElement::SlaveElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||
SlaveElement::SlaveElement(const ElementsLocation &location,
|
||||
QGraphicsItem *qgi,
|
||||
int *state) :
|
||||
Element(location, qgi, state, Element::Slave)
|
||||
{
|
||||
m_xref_item = nullptr;
|
||||
|
||||
@@ -25,7 +25,9 @@ class SlaveElement : public Element
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SlaveElement (const ElementsLocation &, QGraphicsItem * = nullptr, int * = nullptr);
|
||||
explicit SlaveElement (const ElementsLocation &,
|
||||
QGraphicsItem * = nullptr,
|
||||
int * = nullptr);
|
||||
~SlaveElement() override;
|
||||
void linkToElement(Element *elmt) override;
|
||||
void unlinkAllElements() override;
|
||||
|
||||
@@ -31,7 +31,9 @@
|
||||
@param parent_template : TitleBlockTemplate
|
||||
@param parent : QWidget
|
||||
*/
|
||||
TitleBlockTemplateCellWidget::TitleBlockTemplateCellWidget(TitleBlockTemplate *parent_template, QWidget *parent) :
|
||||
TitleBlockTemplateCellWidget::TitleBlockTemplateCellWidget(
|
||||
TitleBlockTemplate *parent_template,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
read_only_(false)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,9 @@ int TitleBlockTemplateLocation::MetaTypeId = qRegisterMetaType<TitleBlockTemplat
|
||||
@param collection Parent collection of the title block template
|
||||
@param name Name of the title block template within its parent project or collection
|
||||
*/
|
||||
TitleBlockTemplateLocation::TitleBlockTemplateLocation(const QString &name, TitleBlockTemplatesCollection *collection) :
|
||||
TitleBlockTemplateLocation::TitleBlockTemplateLocation(
|
||||
const QString &name,
|
||||
TitleBlockTemplatesCollection *collection) :
|
||||
collection_(collection),
|
||||
name_(name)
|
||||
{
|
||||
@@ -42,7 +44,8 @@ TitleBlockTemplateLocation::~TitleBlockTemplateLocation() {
|
||||
/**
|
||||
@param loc_str String describing the location of a title block template.
|
||||
*/
|
||||
TitleBlockTemplateLocation TitleBlockTemplateLocation::locationFromString(const QString &loc_str) {
|
||||
TitleBlockTemplateLocation TitleBlockTemplateLocation::locationFromString(
|
||||
const QString &loc_str) {
|
||||
TitleBlockTemplateLocation loc;
|
||||
loc.fromString(loc_str);
|
||||
return(loc);
|
||||
@@ -59,7 +62,8 @@ TitleBlockTemplatesCollection *TitleBlockTemplateLocation::parentCollection() co
|
||||
@brief TitleBlockTemplateLocation::setParentCollection
|
||||
@param collection : TitleBlockTemplatesCollection
|
||||
*/
|
||||
void TitleBlockTemplateLocation::setParentCollection(TitleBlockTemplatesCollection *collection) {
|
||||
void TitleBlockTemplateLocation::setParentCollection(
|
||||
TitleBlockTemplatesCollection *collection) {
|
||||
collection_ = collection;
|
||||
}
|
||||
|
||||
@@ -158,7 +162,8 @@ bool TitleBlockTemplateLocation::isReadOnly() const {
|
||||
@param location other location that should be compared to this one
|
||||
@return true if locations are equal, false otherwise
|
||||
*/
|
||||
bool TitleBlockTemplateLocation::operator==(const TitleBlockTemplateLocation &location) const {
|
||||
bool TitleBlockTemplateLocation::operator==(
|
||||
const TitleBlockTemplateLocation &location) const {
|
||||
return(location.collection_ == collection_ && location.name_ == name_);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ class TitleBlockTemplatesCollection;
|
||||
class TitleBlockTemplateLocation {
|
||||
// constructor, destructor
|
||||
public:
|
||||
TitleBlockTemplateLocation(const QString & = QString(), TitleBlockTemplatesCollection * = nullptr);
|
||||
TitleBlockTemplateLocation(const QString & = QString(),
|
||||
TitleBlockTemplatesCollection * = nullptr);
|
||||
virtual ~TitleBlockTemplateLocation();
|
||||
|
||||
// static methods
|
||||
@@ -54,8 +55,9 @@ class TitleBlockTemplateLocation {
|
||||
|
||||
// attributes
|
||||
private:
|
||||
TitleBlockTemplatesCollection *collection_; ///< Collection the template belongs to
|
||||
QString name_; ///< Name of the template
|
||||
TitleBlockTemplatesCollection
|
||||
*collection_; ///< Collection the template belongs to
|
||||
QString name_;///< Name of the template
|
||||
|
||||
public:
|
||||
static int MetaTypeId; ///< Id of the corresponding Qt meta type
|
||||
|
||||
@@ -68,7 +68,8 @@ QString TitleBlockTemplateLocationChooser::name() const {
|
||||
Set the location displayed by this widget
|
||||
@param location to be displayed by this widget
|
||||
*/
|
||||
void TitleBlockTemplateLocationChooser::setLocation(const TitleBlockTemplateLocation &location) {
|
||||
void TitleBlockTemplateLocationChooser::setLocation(
|
||||
const TitleBlockTemplateLocation &location) {
|
||||
int index = indexForCollection(location.parentCollection());
|
||||
collections_ -> setCurrentIndex(index);
|
||||
|
||||
@@ -91,11 +92,14 @@ void TitleBlockTemplateLocationChooser::init() {
|
||||
templates_ = new QComboBox();
|
||||
|
||||
updateCollections();
|
||||
connect(collections_, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTemplates()));
|
||||
connect(collections_, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(updateTemplates()));
|
||||
|
||||
form_layout_ = new QFormLayout();
|
||||
form_layout_ -> addRow(tr("Collection parente", "used in save as form"), collections_);
|
||||
form_layout_ -> addRow(tr("Modèle existant", "used in save as form"), templates_);
|
||||
form_layout_ -> addRow(tr("Collection parente","used in save as form"),
|
||||
collections_);
|
||||
form_layout_ -> addRow(tr("Modèle existant","used in save as form"),
|
||||
templates_);
|
||||
setLayout(form_layout_);
|
||||
}
|
||||
|
||||
@@ -106,7 +110,8 @@ void TitleBlockTemplateLocationChooser::init() {
|
||||
@return -1 if the collection is unknown to this dialog,
|
||||
or the index of \a coll
|
||||
*/
|
||||
int TitleBlockTemplateLocationChooser::indexForCollection(TitleBlockTemplatesCollection *coll) const {
|
||||
int TitleBlockTemplateLocationChooser::indexForCollection(
|
||||
TitleBlockTemplatesCollection *coll) const {
|
||||
QList<int> indexes = collections_index_.keys(coll);
|
||||
if (indexes.count()) return(indexes.first());
|
||||
return(-1);
|
||||
@@ -120,7 +125,8 @@ void TitleBlockTemplateLocationChooser::updateCollections() {
|
||||
collections_index_.clear();
|
||||
|
||||
int index = 0;
|
||||
foreach(TitleBlockTemplatesCollection *collection, QETApp::availableTitleBlockTemplatesCollections()) {
|
||||
foreach(TitleBlockTemplatesCollection *collection,
|
||||
QETApp::availableTitleBlockTemplatesCollections()) {
|
||||
collections_ -> addItem(collection -> title());
|
||||
collections_index_.insert(index, collection);
|
||||
++ index;
|
||||
|
||||
@@ -29,10 +29,12 @@ class TitleBlockTemplateLocationChooser : public QWidget {
|
||||
Q_OBJECT
|
||||
// Constructor, destructor
|
||||
public:
|
||||
TitleBlockTemplateLocationChooser(const TitleBlockTemplateLocation &, QWidget * = nullptr);
|
||||
TitleBlockTemplateLocationChooser(const TitleBlockTemplateLocation &,
|
||||
QWidget * = nullptr);
|
||||
~TitleBlockTemplateLocationChooser() override;
|
||||
private:
|
||||
TitleBlockTemplateLocationChooser(const TitleBlockTemplateLocationChooser &);
|
||||
TitleBlockTemplateLocationChooser(
|
||||
const TitleBlockTemplateLocationChooser &);
|
||||
|
||||
// methods
|
||||
public:
|
||||
|
||||
@@ -31,7 +31,8 @@ class TitleBlockTemplateLocationSaver : public TitleBlockTemplateLocationChooser
|
||||
Q_OBJECT
|
||||
// Constructor, destructor
|
||||
public:
|
||||
TitleBlockTemplateLocationSaver(const TitleBlockTemplateLocation &, QWidget * = nullptr);
|
||||
TitleBlockTemplateLocationSaver(const TitleBlockTemplateLocation &,
|
||||
QWidget * = nullptr);
|
||||
~TitleBlockTemplateLocationSaver() override;
|
||||
private:
|
||||
TitleBlockTemplateLocationSaver(const TitleBlockTemplateLocationSaver &);
|
||||
|
||||
@@ -56,7 +56,8 @@ TitleBlockTemplateView::TitleBlockTemplateView(QWidget *parent) :
|
||||
@param scene
|
||||
@param parent Parent QWidget.
|
||||
*/
|
||||
TitleBlockTemplateView::TitleBlockTemplateView(QGraphicsScene *scene, QWidget *parent) :
|
||||
TitleBlockTemplateView::TitleBlockTemplateView(QGraphicsScene *scene,
|
||||
QWidget *parent) :
|
||||
QGraphicsView(scene, parent),
|
||||
tbtemplate_(nullptr),
|
||||
tbgrid_(nullptr),
|
||||
@@ -453,7 +454,9 @@ TitleBlockTemplateCellsSet TitleBlockTemplateView::cells(const QRectF &rect) con
|
||||
@param count :
|
||||
If non-zero, will be changed to reflect the number of selected cells
|
||||
*/
|
||||
void TitleBlockTemplateView::analyzeSelectedCells(bool *can_merge, bool *can_split, int *count) {
|
||||
void TitleBlockTemplateView::analyzeSelectedCells(bool *can_merge,
|
||||
bool *can_split,
|
||||
int *count) {
|
||||
if (!can_merge && !can_split) return;
|
||||
|
||||
if (!tbtemplate_) {
|
||||
@@ -834,7 +837,10 @@ bool TitleBlockTemplateView::event(QEvent *event) {
|
||||
@param x : row
|
||||
@param y : column
|
||||
*/
|
||||
void TitleBlockTemplateView::normalizeCells(QList<TitleBlockCell> &cells, int x, int y) const {
|
||||
void TitleBlockTemplateView::normalizeCells(
|
||||
QList<TitleBlockCell> &cells,
|
||||
int x,
|
||||
int y) const {
|
||||
if (!cells.count()) return;
|
||||
|
||||
int min_row = cells.at(0).num_row;
|
||||
@@ -1064,7 +1070,8 @@ void TitleBlockTemplateView::removeItem(QGraphicsLayoutItem *item) {
|
||||
@param items : a list of QGraphicsItem
|
||||
@return the corresponding TitleBlockTemplateCellsSet
|
||||
*/
|
||||
TitleBlockTemplateCellsSet TitleBlockTemplateView::makeCellsSetFromGraphicsItems(const QList<QGraphicsItem *> &items) const {
|
||||
TitleBlockTemplateCellsSet TitleBlockTemplateView::makeCellsSetFromGraphicsItems(
|
||||
const QList<QGraphicsItem *> &items) const {
|
||||
TitleBlockTemplateCellsSet set(this);
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
if (TitleBlockTemplateVisualCell *cell_view = dynamic_cast<TitleBlockTemplateVisualCell *>(item)) {
|
||||
|
||||
@@ -35,7 +35,8 @@ class TitleBlockTemplateView : public QGraphicsView {
|
||||
// constructors, destructor
|
||||
public:
|
||||
TitleBlockTemplateView(QWidget * = nullptr);
|
||||
TitleBlockTemplateView(QGraphicsScene *, QWidget * = nullptr);
|
||||
TitleBlockTemplateView(QGraphicsScene *,
|
||||
QWidget * = nullptr);
|
||||
~TitleBlockTemplateView() override;
|
||||
private:
|
||||
TitleBlockTemplateView(const TitleBlockTemplateView &);
|
||||
@@ -99,7 +100,9 @@ class TitleBlockTemplateView : public QGraphicsView {
|
||||
virtual qreal zoomFactor() const;
|
||||
virtual void fillWithEmptyCells();
|
||||
bool event(QEvent *) override;
|
||||
virtual void normalizeCells(QList<TitleBlockCell> &, int x = 0, int y = 0) const;
|
||||
virtual void normalizeCells(QList<TitleBlockCell> &,
|
||||
int x = 0,
|
||||
int y = 0) const;
|
||||
|
||||
signals:
|
||||
void selectedCellsChanged(QList<TitleBlockCell *>);
|
||||
@@ -114,7 +117,8 @@ class TitleBlockTemplateView : public QGraphicsView {
|
||||
int lastContextMenuCellIndex() const;
|
||||
int indexOf(QGraphicsLayoutItem *);
|
||||
void removeItem(QGraphicsLayoutItem *);
|
||||
TitleBlockTemplateCellsSet makeCellsSetFromGraphicsItems(const QList<QGraphicsItem *> &) const;
|
||||
TitleBlockTemplateCellsSet makeCellsSetFromGraphicsItems(
|
||||
const QList<QGraphicsItem *> &) const;
|
||||
QString makePrettyToolTip(const QString &);
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -32,7 +32,11 @@
|
||||
@param project : QETProject
|
||||
@param parent parent widget
|
||||
*/
|
||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock, bool current_date, QETProject *project, QWidget *parent) :
|
||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(
|
||||
const TitleBlockProperties &titleblock,
|
||||
bool current_date,
|
||||
QETProject *project,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::TitleBlockPropertiesWidget)
|
||||
{
|
||||
@@ -50,7 +54,12 @@ TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(const TitleBlockPropertie
|
||||
@param project : QETProject
|
||||
@param parent parent widget
|
||||
*/
|
||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock, bool current_date, QETProject *project, QWidget *parent) :
|
||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(
|
||||
TitleBlockTemplatesCollection *tbt_collection,
|
||||
const TitleBlockProperties &titleblock,
|
||||
bool current_date,
|
||||
QETProject *project,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::TitleBlockPropertiesWidget)
|
||||
{
|
||||
@@ -70,7 +79,12 @@ TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(TitleBlockTemplatesCollec
|
||||
@param project : QETProject
|
||||
@param parent parent widget
|
||||
*/
|
||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(QList<TitleBlockTemplatesCollection *> tbt_collection, const TitleBlockProperties &titleblock, bool current_date, QETProject *project, QWidget *parent) :
|
||||
TitleBlockPropertiesWidget::TitleBlockPropertiesWidget(
|
||||
QList<TitleBlockTemplatesCollection *> tbt_collection,
|
||||
const TitleBlockProperties &titleblock,
|
||||
bool current_date,
|
||||
QETProject *project,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::TitleBlockPropertiesWidget)
|
||||
{
|
||||
@@ -95,7 +109,8 @@ TitleBlockPropertiesWidget::~TitleBlockPropertiesWidget()
|
||||
@brief TitleBlockPropertiesWidget::setProperties
|
||||
@param properties
|
||||
*/
|
||||
void TitleBlockPropertiesWidget::setProperties(const TitleBlockProperties &properties) {
|
||||
void TitleBlockPropertiesWidget::setProperties(
|
||||
const TitleBlockProperties &properties) {
|
||||
ui -> m_title_le -> setText (properties.title);
|
||||
ui -> m_author_le -> setText (properties.author);
|
||||
ui -> m_file_le -> setText (properties.filename);
|
||||
@@ -193,7 +208,8 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const {
|
||||
@brief TitleBlockPropertiesWidget::properties
|
||||
@return return properties to enable folio autonum
|
||||
*/
|
||||
TitleBlockProperties TitleBlockPropertiesWidget::propertiesAutoNum(QString autoNum) const {
|
||||
TitleBlockProperties TitleBlockPropertiesWidget::propertiesAutoNum(
|
||||
QString autoNum) const {
|
||||
TitleBlockProperties prop;
|
||||
prop.title = ui -> m_title_le -> text();
|
||||
prop.author = ui -> m_author_le -> text();
|
||||
@@ -248,7 +264,8 @@ TitleBlockTemplateLocation TitleBlockPropertiesWidget::currentTitleBlockLocation
|
||||
@brief TitleBlockPropertiesWidget::setTitleBlockTemplatesVisible
|
||||
if true, title block template combo box and menu button is visible
|
||||
*/
|
||||
void TitleBlockPropertiesWidget::setTitleBlockTemplatesVisible(const bool &visible) {
|
||||
void TitleBlockPropertiesWidget::setTitleBlockTemplatesVisible(
|
||||
const bool &visible) {
|
||||
ui -> m_tbt_label -> setVisible(visible);
|
||||
ui -> m_tbt_cb -> setVisible(visible);
|
||||
ui -> m_tbt_pb -> setVisible(visible);
|
||||
@@ -278,7 +295,8 @@ QString TitleBlockPropertiesWidget::currentTitleBlockTemplateName() const {
|
||||
add a collection of title block available in the combo box
|
||||
@param tbt_collection
|
||||
*/
|
||||
void TitleBlockPropertiesWidget::addCollection(TitleBlockTemplatesCollection *tbt_collection)
|
||||
void TitleBlockPropertiesWidget::addCollection(
|
||||
TitleBlockTemplatesCollection *tbt_collection)
|
||||
{
|
||||
if (!tbt_collection || m_tbt_collection_list.contains(tbt_collection)) return;
|
||||
m_tbt_collection_list << tbt_collection;
|
||||
@@ -290,7 +308,8 @@ void TitleBlockPropertiesWidget::addCollection(TitleBlockTemplatesCollection *tb
|
||||
@param current_date : true for display current date radio button
|
||||
@param project
|
||||
*/
|
||||
void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date, QETProject *project) {
|
||||
void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date,
|
||||
QETProject *project) {
|
||||
m_dcw = new DiagramContextWidget();
|
||||
ui -> m_tab2_vlayout -> addWidget(m_dcw);
|
||||
|
||||
@@ -298,17 +317,28 @@ void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date, QETProjec
|
||||
ui -> m_current_date_rb -> setVisible(current_date);
|
||||
|
||||
m_tbt_edit = new QAction(tr("Éditer ce modèle", "menu entry"), this);
|
||||
m_tbt_duplicate = new QAction(tr("Dupliquer et éditer ce modèle", "menu entry"), this);
|
||||
m_tbt_duplicate = new QAction(tr("Dupliquer et éditer ce modèle",
|
||||
"menu entry"),
|
||||
this);
|
||||
|
||||
connect(m_tbt_edit, SIGNAL(triggered()), this, SLOT(editCurrentTitleBlockTemplate()));
|
||||
connect(m_tbt_duplicate, SIGNAL(triggered()), this, SLOT(duplicateCurrentTitleBlockTemplate()));
|
||||
connect(m_tbt_edit,
|
||||
SIGNAL(triggered()),
|
||||
this,
|
||||
SLOT(editCurrentTitleBlockTemplate()));
|
||||
connect(m_tbt_duplicate,
|
||||
SIGNAL(triggered()),
|
||||
this,
|
||||
SLOT(duplicateCurrentTitleBlockTemplate()));
|
||||
|
||||
m_tbt_menu = new QMenu(tr("Title block templates actions"));
|
||||
m_tbt_menu -> addAction(m_tbt_edit);
|
||||
m_tbt_menu -> addAction(m_tbt_duplicate);
|
||||
ui -> m_tbt_pb -> setMenu(m_tbt_menu);
|
||||
|
||||
connect(ui->m_tbt_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentTitleBlockTemplate(int)));
|
||||
connect(ui->m_tbt_cb,
|
||||
SIGNAL(currentIndexChanged(int)),
|
||||
this,
|
||||
SLOT(changeCurrentTitleBlockTemplate(int)));
|
||||
|
||||
if (project!= nullptr){
|
||||
keys_2 = project -> folioAutoNum().keys();
|
||||
@@ -332,7 +362,9 @@ void TitleBlockPropertiesWidget::initDialog(const bool ¤t_date, QETProjec
|
||||
@param collection : title block collection
|
||||
@return the index of the title block or -1 if no match
|
||||
*/
|
||||
int TitleBlockPropertiesWidget::getIndexFor(const QString &tbt_name, const QET::QetCollection collection) const
|
||||
int TitleBlockPropertiesWidget::getIndexFor(
|
||||
const QString &tbt_name,
|
||||
const QET::QetCollection collection) const
|
||||
{
|
||||
for (int i = 0; i<ui->m_tbt_cb->count(); i++) {
|
||||
if (ui->m_tbt_cb->itemData(i).toString() == tbt_name)
|
||||
|
||||
@@ -39,25 +39,43 @@ class TitleBlockPropertiesWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TitleBlockPropertiesWidget(const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QETProject *project = nullptr, QWidget *parent = nullptr);
|
||||
explicit TitleBlockPropertiesWidget(TitleBlockTemplatesCollection *tbt_collection, const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QETProject *project = nullptr, QWidget *parent = nullptr);
|
||||
explicit TitleBlockPropertiesWidget(QList <TitleBlockTemplatesCollection *> tbt_collection, const TitleBlockProperties &titleblock = TitleBlockProperties(), bool current_date = false, QETProject *project = nullptr, QWidget *parent = nullptr);
|
||||
explicit TitleBlockPropertiesWidget(
|
||||
const TitleBlockProperties &titleblock = TitleBlockProperties(),
|
||||
bool current_date = false,
|
||||
QETProject *project = nullptr,
|
||||
QWidget *parent = nullptr);
|
||||
explicit TitleBlockPropertiesWidget(
|
||||
TitleBlockTemplatesCollection *tbt_collection,
|
||||
const TitleBlockProperties &titleblock = TitleBlockProperties(),
|
||||
bool current_date = false,
|
||||
QETProject *project = nullptr,
|
||||
QWidget *parent = nullptr);
|
||||
explicit TitleBlockPropertiesWidget(
|
||||
QList <TitleBlockTemplatesCollection *> tbt_collection,
|
||||
const TitleBlockProperties &titleblock = TitleBlockProperties(),
|
||||
bool current_date = false,
|
||||
QETProject *project = nullptr,
|
||||
QWidget *parent = nullptr);
|
||||
~TitleBlockPropertiesWidget() override;
|
||||
|
||||
void setProperties(const TitleBlockProperties &properties);
|
||||
TitleBlockProperties properties() const;
|
||||
TitleBlockProperties propertiesAutoNum(QString autoNum) const;
|
||||
TitleBlockTemplateLocation currentTitleBlockLocation () const;
|
||||
void setPropertiesWithAutoNum(const TitleBlockProperties &properties, QString autoNum);
|
||||
void setPropertiesWithAutoNum(
|
||||
const TitleBlockProperties &properties,
|
||||
QString autoNum);
|
||||
|
||||
void setTitleBlockTemplatesVisible(const bool &visible);
|
||||
void setReadOnly (const bool &ro);
|
||||
|
||||
private:
|
||||
void addCollection (TitleBlockTemplatesCollection *tbt_collection);
|
||||
void addCollection (
|
||||
TitleBlockTemplatesCollection *tbt_collection);
|
||||
QString currentTitleBlockTemplateName () const;
|
||||
void initDialog(const bool ¤t_date, QETProject *project);
|
||||
int getIndexFor (const QString &tbt_name, const QET::QetCollection collection) const;
|
||||
int getIndexFor (const QString &tbt_name,
|
||||
const QET::QetCollection collection) const;
|
||||
|
||||
private slots:
|
||||
void editCurrentTitleBlockTemplate();
|
||||
|
||||
Reference in New Issue
Block a user