mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-01 04:53:13 +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
|
||||
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).
|
||||
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'.
|
||||
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).
|
||||
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.
|
||||
At the time this sentence is written, there is two identifier :
|
||||
nomenclature
|
||||
@@ -45,10 +50,18 @@ class ProjectDBModel : public QAbstractTableModel
|
||||
|
||||
int rowCount(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;
|
||||
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;
|
||||
bool setHeaderData(int section,
|
||||
Qt::Orientation orientation,
|
||||
const QVariant &value,
|
||||
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);
|
||||
QString queryString() const;
|
||||
QETProject *project() const;
|
||||
@@ -68,7 +81,8 @@ class ProjectDBModel : public QAbstractTableModel
|
||||
QPointer<QETProject> m_project;
|
||||
QString m_query;
|
||||
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;
|
||||
QString m_identifier = "unknow";
|
||||
};
|
||||
|
||||
@@ -2006,8 +2006,9 @@ Conductor * longuestConductorInPotential(Conductor *conductor, bool all_diagram)
|
||||
/**
|
||||
@brief relatedConductors
|
||||
@param conductor
|
||||
@return return all conductors who share the same terminals of @conductor given as parametre,
|
||||
except @conductor himself.
|
||||
@return return all conductors who share the same terminals
|
||||
of conductor given as parametre,
|
||||
except conductor himself.
|
||||
*/
|
||||
QList <Conductor *> relatedConductors(const Conductor *conductor) {
|
||||
QList<Conductor *> other_conductors_list = conductor -> terminal1 -> conductors();
|
||||
|
||||
@@ -38,9 +38,9 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||
Constructeur
|
||||
@param text Le texte affiche par le champ de texte
|
||||
@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),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
|
||||
@@ -85,7 +85,9 @@ class DiagramTextItem : public QGraphicsTextItem
|
||||
bool isHtml() const;
|
||||
|
||||
protected:
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
void paint(QPainter *,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
void focusInEvent(QFocusEvent *) override;
|
||||
void focusOutEvent(QFocusEvent *) override;
|
||||
|
||||
@@ -104,12 +106,14 @@ class DiagramTextItem : public QGraphicsTextItem
|
||||
|
||||
|
||||
protected:
|
||||
bool m_mouse_hover = false,
|
||||
bool
|
||||
m_mouse_hover = false,
|
||||
m_first_move = true,
|
||||
m_no_editable,
|
||||
m_is_html = false;
|
||||
|
||||
QString m_previous_html_text,
|
||||
QString
|
||||
m_previous_html_text,
|
||||
m_previous_text;
|
||||
|
||||
QPointF m_mouse_to_origin_movement;
|
||||
|
||||
@@ -134,13 +134,14 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
QString reportReplacedCompositeText() const;
|
||||
void zoomToLinkedElement();
|
||||
|
||||
|
||||
private:
|
||||
QPointer <Element> m_parent_element,
|
||||
QPointer <Element>
|
||||
m_parent_element,
|
||||
m_master_element,
|
||||
m_other_report;
|
||||
QPointer <Conductor> m_watched_conductor;
|
||||
QString m_text,
|
||||
QString
|
||||
m_text,
|
||||
m_info_name,
|
||||
m_composite_text,
|
||||
m_report_formula,
|
||||
@@ -148,10 +149,12 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
||||
QUuid m_uuid;
|
||||
QMetaObject::Connection m_report_formula_con;
|
||||
QList<QMetaObject::Connection> m_formula_connection,
|
||||
QList<QMetaObject::Connection>
|
||||
m_formula_connection,
|
||||
m_update_slave_Xref_connection;
|
||||
QColor m_user_color;
|
||||
bool m_frame = false,
|
||||
bool
|
||||
m_frame = false,
|
||||
m_first_scene_change = true;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||
|
||||
@@ -221,8 +221,9 @@ void QetShapeItem::setNextPoint(QPointF P)
|
||||
/**
|
||||
@brief QetShapeItem::removePoints
|
||||
Number of point to remove on the polygon
|
||||
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);
|
||||
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);
|
||||
*/
|
||||
void QetShapeItem::removePoints(int number)
|
||||
{
|
||||
@@ -264,7 +265,9 @@ QPainterPath QetShapeItem::shape() const
|
||||
path.lineTo(m_P2);
|
||||
break;
|
||||
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;
|
||||
case Ellipse:
|
||||
path.addEllipse(QRectF(m_P1, m_P2));
|
||||
@@ -292,7 +295,9 @@ QPainterPath QetShapeItem::shape() const
|
||||
@param option
|
||||
@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(widget)
|
||||
@@ -317,9 +322,12 @@ void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
switch (m_shapeType)
|
||||
{
|
||||
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 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();
|
||||
@@ -364,11 +372,13 @@ void QetShapeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
@param value
|
||||
@return
|
||||
*/
|
||||
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
QVariant QetShapeItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
const QVariant &value)
|
||||
{
|
||||
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();
|
||||
}
|
||||
else //Else this is deselected, we remove handlers
|
||||
@@ -958,9 +968,30 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
||||
|
||||
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 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;
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user