mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-12 04:09:59 +01:00
TerminalStripLayoutPattern is now shared
TerminalStripLayoutPattern class is now a shared pointer between all terminal strip item. QETProject have now a new class : ProjectPropertiesHandler the goal of this class is to manage every kind of properties used in the project, this class will be strongly used in future.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright 2006-2022 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 "terminalstriplayoutpattern.h"
|
||||
#include <QDebug>
|
||||
|
||||
TerminalStripLayoutPattern::TerminalStripLayoutPattern()
|
||||
{
|
||||
updateHeaderTextOption();
|
||||
updateTerminalsTextOption();
|
||||
}
|
||||
|
||||
void TerminalStripLayoutPattern::setHeaderTextAlignment(const Qt::Alignment &alignment)
|
||||
{
|
||||
m_header_text_alignment = alignment;
|
||||
updateHeaderTextOption();
|
||||
}
|
||||
|
||||
Qt::Alignment TerminalStripLayoutPattern::headerTextAlignment() const
|
||||
{
|
||||
return m_header_text_alignment;
|
||||
}
|
||||
|
||||
QTextOption TerminalStripLayoutPattern::headerTextOption() const {
|
||||
return m_header_text_option;
|
||||
}
|
||||
|
||||
void TerminalStripLayoutPattern::setTerminalsTextAlignment(const QVector<Qt::Alignment> &alignment)
|
||||
{
|
||||
m_terminals_text_alignment = alignment;
|
||||
updateTerminalsTextOption();
|
||||
}
|
||||
|
||||
QVector<Qt::Alignment> TerminalStripLayoutPattern::terminalsTextAlignment() const
|
||||
{
|
||||
return m_terminals_text_alignment;
|
||||
}
|
||||
|
||||
QVector<QTextOption> TerminalStripLayoutPattern::terminalsTextOption() const
|
||||
{
|
||||
return m_terminals_text_option;
|
||||
}
|
||||
|
||||
void TerminalStripLayoutPattern::updateHeaderTextOption()
|
||||
{
|
||||
m_header_text_option.setAlignment(m_header_text_alignment);
|
||||
m_header_text_option.setWrapMode(QTextOption::WordWrap);
|
||||
}
|
||||
|
||||
void TerminalStripLayoutPattern::updateTerminalsTextOption()
|
||||
{
|
||||
if (m_terminals_text_option.size() ==
|
||||
m_terminals_text_alignment.size())
|
||||
{
|
||||
for (auto i = 0 ; i<m_terminals_text_option.size() ; ++i)
|
||||
{
|
||||
m_terminals_text_option[i].setAlignment(m_terminals_text_alignment.at(i));
|
||||
m_terminals_text_option[i].setWrapMode(QTextOption::WordWrap);
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "TerminalStripLayoutPattern::updateTerminalsTextOption() : Wrong vector size";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
Copyright 2006-2022 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 TERMINALSTRIPLAYOUTPATTERN_H
|
||||
#define TERMINALSTRIPLAYOUTPATTERN_H
|
||||
|
||||
#include <QSize>
|
||||
#include <QTextOption>
|
||||
#include <QVector>
|
||||
#include <QRect>
|
||||
|
||||
/**
|
||||
* @brief The TerminalStripLayoutPattern class
|
||||
* A class with all values used to define how a terminal strip must be drawn.
|
||||
* Most of the value are public, some values are private and have getter / setter
|
||||
* because when these values change we need to compute the change.
|
||||
*
|
||||
* The values with name '_y_offset' mean offset is relating to the top
|
||||
* of the QGraphicsItem used to display the terminal strip.
|
||||
*
|
||||
* The terminal strip can display up to 4 terminal level,
|
||||
* the value used for multilevel terminal are stored in several QVector (m_terminal_y_offset, m_terminal_height, m_bridge_point_y_offset).
|
||||
* The order of the values are from the most back terminal to the front terminal.
|
||||
*/
|
||||
class TerminalStripLayoutPattern
|
||||
{
|
||||
public:
|
||||
TerminalStripLayoutPattern();
|
||||
|
||||
//Header of terminal strip
|
||||
QRect m_header_rect{0,30,50,130};
|
||||
Qt::Orientation m_header_text_orientation{Qt::Horizontal};
|
||||
void setHeaderTextAlignment(const Qt::Alignment &alignment);
|
||||
Qt::Alignment headerTextAlignment() const;
|
||||
QTextOption headerTextOption() const;
|
||||
|
||||
//Spacer between the header and the terminals
|
||||
QRect m_spacer_rect{0, 50, 10, 90};
|
||||
|
||||
//Terminals
|
||||
QVector<QRect> m_terminal_rect
|
||||
{
|
||||
QRect{0, 0, 20, 190},
|
||||
QRect{0, 10, 20, 170},
|
||||
QRect{0, 20, 20, 150},
|
||||
QRect{0, 30, 20, 130}
|
||||
};
|
||||
|
||||
void setTerminalsTextAlignment(const QVector<Qt::Alignment> &alignment);
|
||||
QVector<Qt::Alignment> terminalsTextAlignment() const;
|
||||
QVector<QTextOption> terminalsTextOption() const;
|
||||
|
||||
QVector<QRect> m_terminals_text_rect
|
||||
{
|
||||
QRect{0,35,20,50},
|
||||
QRect{0,35,20,50},
|
||||
QRect{0,35,20,50},
|
||||
QRect{0,35,20,50}
|
||||
};
|
||||
QVector<Qt::Orientation> m_terminals_text_orientation
|
||||
{
|
||||
Qt::Vertical,
|
||||
Qt::Vertical,
|
||||
Qt::Vertical,
|
||||
Qt::Vertical
|
||||
};
|
||||
|
||||
int m_bridge_point_d{5};
|
||||
QVector<int> m_bridge_point_y_offset{50,70,90,110};
|
||||
|
||||
QUuid m_uuid{QUuid::createUuid()};
|
||||
QString m_name;
|
||||
|
||||
private:
|
||||
void updateHeaderTextOption();
|
||||
void updateTerminalsTextOption();
|
||||
|
||||
private:
|
||||
Qt::Alignment m_header_text_alignment{Qt::AlignCenter};
|
||||
QTextOption m_header_text_option;
|
||||
|
||||
QVector<Qt::Alignment> m_terminals_text_alignment
|
||||
{
|
||||
Qt::AlignRight | Qt::AlignVCenter,
|
||||
Qt::AlignRight | Qt::AlignVCenter,
|
||||
Qt::AlignRight | Qt::AlignVCenter,
|
||||
Qt::AlignRight | Qt::AlignVCenter
|
||||
};
|
||||
QVector<QTextOption> m_terminals_text_option
|
||||
{
|
||||
QTextOption(),
|
||||
QTextOption(),
|
||||
QTextOption(),
|
||||
QTextOption()
|
||||
};
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPLAYOUTPATTERN_H
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2006-2023 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 "terminalstriplayoutshandler.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
TerminalStripLayoutsHandler::TerminalStripLayoutsHandler()
|
||||
{
|
||||
m_default_layout = new TerminalStripLayoutPattern;
|
||||
m_default_layout->m_name = QObject("Disposition par défaut");
|
||||
}
|
||||
|
||||
QSharedPointer<TerminalStripLayoutPattern> TerminalStripLayoutsHandler::defaultLayout()
|
||||
{
|
||||
return m_default_layout;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2006-2023 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 TERMINALSTRIPLAYOUTSHANDLER_H
|
||||
#define TERMINALSTRIPLAYOUTSHANDLER_H
|
||||
|
||||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "terminalstriplayoutpattern.h"
|
||||
|
||||
/**
|
||||
* @brief The TerminalStripLayoutsHandler class
|
||||
* Manage and provide TerminalStripLayoutPattern
|
||||
*/
|
||||
class TerminalStripLayoutsHandler
|
||||
{
|
||||
public:
|
||||
TerminalStripLayoutsHandler();
|
||||
QSharedPointer<TerminalStripLayoutPattern> defaultLayout();
|
||||
|
||||
private:
|
||||
QSet<QSharedPointer<TerminalStripLayoutPattern>> m_layout_set;
|
||||
QSharedPointer<TerminalStripLayoutPattern> m_default_layout;
|
||||
};
|
||||
|
||||
#endif // TERMINALSTRIPLAYOUTSHANDLER_H
|
||||
Reference in New Issue
Block a user