mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-22 13:19:58 +02:00
Improve code style, Wrap code for better readability, Mod doc
This commit is contained in:
@@ -26,10 +26,15 @@ class QETProject;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The ProjectDBModel class
|
@brief The ProjectDBModel class
|
||||||
This model is intended to be use with the @class projectDataBase
|
This model is intended to be use with the class projectDataBase
|
||||||
and is designed to be displayed by the @class QetGraphicsTableItem (but can be use by other view class since it inherit from QAbstractTableModel).
|
and is designed to be displayed by the class QetGraphicsTableItem
|
||||||
This class should be sufficient to display the content of the project data base from a query set by the method void ProjectDBModel::setQuery(const QString &query).
|
(but can be use by other view class since it inherit from QAbstractTableModel).
|
||||||
The indentifier method is used by widget editor to retrieve the good widget for edit the query. By defaut identifer return the string 'unknow'.
|
This class should be sufficient to display the content of
|
||||||
|
the project data base from a query set by the method
|
||||||
|
void ProjectDBModel::setQuery(const QString &query).
|
||||||
|
The indentifier method is used by widget editor to retrieve
|
||||||
|
the good widget for edit the query.
|
||||||
|
By defaut identifer return the string 'unknow'.
|
||||||
You should use setIdentfier method to set your custom identifier.
|
You should use setIdentfier method to set your custom identifier.
|
||||||
At the time this sentence is written, there is two identifier :
|
At the time this sentence is written, there is two identifier :
|
||||||
nomenclature
|
nomenclature
|
||||||
@@ -45,10 +50,18 @@ class ProjectDBModel : public QAbstractTableModel
|
|||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
|
bool setHeaderData(int section,
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
Qt::Orientation orientation,
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
const QVariant &value,
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
int role = Qt::EditRole) override;
|
||||||
|
QVariant headerData(int section,
|
||||||
|
Qt::Orientation orientation,
|
||||||
|
int role = Qt::DisplayRole) const override;
|
||||||
|
bool setData(const QModelIndex &index,
|
||||||
|
const QVariant &value,
|
||||||
|
int role = Qt::EditRole) override;
|
||||||
|
QVariant data(const QModelIndex &index,
|
||||||
|
int role = Qt::DisplayRole) const override;
|
||||||
void setQuery(const QString &setQuery);
|
void setQuery(const QString &setQuery);
|
||||||
QString queryString() const;
|
QString queryString() const;
|
||||||
QETProject *project() const;
|
QETProject *project() const;
|
||||||
@@ -68,7 +81,8 @@ class ProjectDBModel : public QAbstractTableModel
|
|||||||
QPointer<QETProject> m_project;
|
QPointer<QETProject> m_project;
|
||||||
QString m_query;
|
QString m_query;
|
||||||
QVector<QStringList> m_record;
|
QVector<QStringList> m_record;
|
||||||
QHash<int, QHash<int, QVariant>> m_header_data; //First int = section, second int = Qt::role, QVariant = value
|
//First int = section, second int = Qt::role, QVariant = value
|
||||||
|
QHash<int, QHash<int, QVariant>> m_header_data;
|
||||||
QHash<int, QVariant> m_index_0_0_data;
|
QHash<int, QVariant> m_index_0_0_data;
|
||||||
QString m_identifier = "unknow";
|
QString m_identifier = "unknow";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2006,8 +2006,9 @@ Conductor * longuestConductorInPotential(Conductor *conductor, bool all_diagram)
|
|||||||
/**
|
/**
|
||||||
@brief relatedConductors
|
@brief relatedConductors
|
||||||
@param conductor
|
@param conductor
|
||||||
@return return all conductors who share the same terminals of @conductor given as parametre,
|
@return return all conductors who share the same terminals
|
||||||
except @conductor himself.
|
of conductor given as parametre,
|
||||||
|
except conductor himself.
|
||||||
*/
|
*/
|
||||||
QList <Conductor *> relatedConductors(const Conductor *conductor) {
|
QList <Conductor *> relatedConductors(const Conductor *conductor) {
|
||||||
QList<Conductor *> other_conductors_list = conductor -> terminal1 -> conductors();
|
QList<Conductor *> other_conductors_list = conductor -> terminal1 -> conductors();
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
|||||||
Constructeur
|
Constructeur
|
||||||
@param text Le texte affiche par le champ de texte
|
@param text Le texte affiche par le champ de texte
|
||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
@param parent_diagram Schema auquel ce texte et son conducteur parent sont rattaches
|
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_conductor) :
|
ConductorTextItem::ConductorTextItem(const QString &text,
|
||||||
|
Conductor *parent_conductor) :
|
||||||
DiagramTextItem(text, parent_conductor),
|
DiagramTextItem(text, parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
|
|||||||
@@ -85,7 +85,9 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||||||
bool isHtml() const;
|
bool isHtml() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint(QPainter *,
|
||||||
|
const QStyleOptionGraphicsItem *,
|
||||||
|
QWidget *) override;
|
||||||
void focusInEvent(QFocusEvent *) override;
|
void focusInEvent(QFocusEvent *) override;
|
||||||
void focusOutEvent(QFocusEvent *) override;
|
void focusOutEvent(QFocusEvent *) override;
|
||||||
|
|
||||||
@@ -104,12 +106,14 @@ class DiagramTextItem : public QGraphicsTextItem
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_mouse_hover = false,
|
bool
|
||||||
|
m_mouse_hover = false,
|
||||||
m_first_move = true,
|
m_first_move = true,
|
||||||
m_no_editable,
|
m_no_editable,
|
||||||
m_is_html = false;
|
m_is_html = false;
|
||||||
|
|
||||||
QString m_previous_html_text,
|
QString
|
||||||
|
m_previous_html_text,
|
||||||
m_previous_text;
|
m_previous_text;
|
||||||
|
|
||||||
QPointF m_mouse_to_origin_movement;
|
QPointF m_mouse_to_origin_movement;
|
||||||
|
|||||||
@@ -134,13 +134,14 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
QString reportReplacedCompositeText() const;
|
QString reportReplacedCompositeText() const;
|
||||||
void zoomToLinkedElement();
|
void zoomToLinkedElement();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer <Element> m_parent_element,
|
QPointer <Element>
|
||||||
|
m_parent_element,
|
||||||
m_master_element,
|
m_master_element,
|
||||||
m_other_report;
|
m_other_report;
|
||||||
QPointer <Conductor> m_watched_conductor;
|
QPointer <Conductor> m_watched_conductor;
|
||||||
QString m_text,
|
QString
|
||||||
|
m_text,
|
||||||
m_info_name,
|
m_info_name,
|
||||||
m_composite_text,
|
m_composite_text,
|
||||||
m_report_formula,
|
m_report_formula,
|
||||||
@@ -148,10 +149,12 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
QMetaObject::Connection m_report_formula_con;
|
QMetaObject::Connection m_report_formula_con;
|
||||||
QList<QMetaObject::Connection> m_formula_connection,
|
QList<QMetaObject::Connection>
|
||||||
|
m_formula_connection,
|
||||||
m_update_slave_Xref_connection;
|
m_update_slave_Xref_connection;
|
||||||
QColor m_user_color;
|
QColor m_user_color;
|
||||||
bool m_frame = false,
|
bool
|
||||||
|
m_frame = false,
|
||||||
m_first_scene_change = true;
|
m_first_scene_change = true;
|
||||||
CrossRefItem *m_Xref_item = nullptr;
|
CrossRefItem *m_Xref_item = nullptr;
|
||||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||||
|
|||||||
@@ -221,8 +221,9 @@ void QetShapeItem::setNextPoint(QPointF P)
|
|||||||
/**
|
/**
|
||||||
@brief QetShapeItem::removePoints
|
@brief QetShapeItem::removePoints
|
||||||
Number of point to remove on the polygon
|
Number of point to remove on the polygon
|
||||||
If @number is superior to number of polygon points-2,
|
If number is superior to number of polygon points-2,
|
||||||
all points of polygon will be removed except the first two (minimum point for the polygon);
|
all points of polygon will be removed except
|
||||||
|
the first two (minimum point for the polygon);
|
||||||
*/
|
*/
|
||||||
void QetShapeItem::removePoints(int number)
|
void QetShapeItem::removePoints(int number)
|
||||||
{
|
{
|
||||||
@@ -264,7 +265,9 @@ QPainterPath QetShapeItem::shape() const
|
|||||||
path.lineTo(m_P2);
|
path.lineTo(m_P2);
|
||||||
break;
|
break;
|
||||||
case Rectangle:
|
case Rectangle:
|
||||||
path.addRoundedRect(QRectF(m_P1, m_P2), m_xRadius, m_yRadius);
|
path.addRoundedRect(QRectF(m_P1, m_P2),
|
||||||
|
m_xRadius,
|
||||||
|
m_yRadius);
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
path.addEllipse(QRectF(m_P1, m_P2));
|
path.addEllipse(QRectF(m_P1, m_P2));
|
||||||
@@ -292,7 +295,9 @@ QPainterPath QetShapeItem::shape() const
|
|||||||
@param option
|
@param option
|
||||||
@param widget
|
@param widget
|
||||||
*/
|
*/
|
||||||
void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void QetShapeItem::paint(QPainter *painter,
|
||||||
|
const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
@@ -317,9 +322,12 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
||||||
case Rectangle: painter->drawRoundedRect(QRectF(m_P1, m_P2), m_xRadius, m_yRadius); break;
|
case Rectangle: painter->drawRoundedRect(QRectF(m_P1, m_P2),
|
||||||
|
m_xRadius,
|
||||||
|
m_yRadius); break;
|
||||||
case Ellipse: painter->drawEllipse(QRectF(m_P1, m_P2)); break;
|
case Ellipse: painter->drawEllipse(QRectF(m_P1, m_P2)); break;
|
||||||
case Polygon: m_closed ? painter->drawPolygon(m_polygon) : painter->drawPolyline(m_polygon); break;
|
case Polygon: m_closed ? painter->drawPolygon(m_polygon)
|
||||||
|
: painter->drawPolyline(m_polygon); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
@@ -364,11 +372,13 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
@param value
|
@param value
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||||
|
const QVariant &value)
|
||||||
{
|
{
|
||||||
if (change == ItemSelectedHasChanged)
|
if (change == ItemSelectedHasChanged)
|
||||||
{
|
{
|
||||||
if (value.toBool() == true) { //If this is selected, wa add handlers.
|
if (value.toBool() == true) {
|
||||||
|
//If this is selected, wa add handlers.
|
||||||
addHandler();
|
addHandler();
|
||||||
}
|
}
|
||||||
else //Else this is deselected, we remove handlers
|
else //Else this is deselected, we remove handlers
|
||||||
@@ -958,9 +968,30 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
|||||||
|
|
||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line: Createdxf::drawLine (filepath, QLineF(mapToScene(m_P1), mapToScene(m_P2)), Createdxf::getcolorCode(pen.color().red(),pen.color().green(),pen.color().blue())); return true;
|
case Line:
|
||||||
case Rectangle: Createdxf::drawRectangle(filepath, QRectF(mapToScene(m_P1), mapToScene(m_P2)).normalized(), Createdxf::getcolorCode(pen.color().red(),pen.color().green(),pen.color().blue())); return true;
|
Createdxf::drawLine(filepath,
|
||||||
case Ellipse: Createdxf::drawEllipse (filepath, QRectF(mapToScene(m_P1), mapToScene(m_P2)).normalized(), Createdxf::getcolorCode(pen.color().red(),pen.color().green(),pen.color().blue())); return true;
|
QLineF(mapToScene(m_P1),
|
||||||
|
mapToScene(m_P2)),
|
||||||
|
Createdxf::getcolorCode(pen.color().red(),
|
||||||
|
pen.color().green(),
|
||||||
|
pen.color().blue()));
|
||||||
|
return true;
|
||||||
|
case Rectangle:
|
||||||
|
Createdxf::drawRectangle(filepath,
|
||||||
|
QRectF(mapToScene(m_P1),
|
||||||
|
mapToScene(m_P2)).normalized(),
|
||||||
|
Createdxf::getcolorCode(pen.color().red(),
|
||||||
|
pen.color().green(),
|
||||||
|
pen.color().blue()));
|
||||||
|
return true;
|
||||||
|
case Ellipse:
|
||||||
|
Createdxf::drawEllipse (filepath,
|
||||||
|
QRectF(mapToScene(m_P1),
|
||||||
|
mapToScene(m_P2)).normalized(),
|
||||||
|
Createdxf::getcolorCode(pen.color().red(),
|
||||||
|
pen.color().green(),
|
||||||
|
pen.color().blue()));
|
||||||
|
return true;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user