Diagram : Constructor need a QETProject

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3564 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-12-21 12:50:26 +00:00
parent 8477d4d928
commit a5b1a92beb
5 changed files with 49 additions and 51 deletions

View File

@@ -41,13 +41,15 @@ const qreal Diagram::margin = 5.0;
// static variable to keep track of present background color of the diagram. // static variable to keep track of present background color of the diagram.
QColor Diagram::background_color = Qt::white; QColor Diagram::background_color = Qt::white;
/** /**
Constructeur * @brief Diagram::Diagram
@param parent Le QObject parent du schema * Constructor
* @param project : The project of this diagram and also parent QObject
*/ */
Diagram::Diagram(QObject *parent) : Diagram::Diagram(QETProject *project) :
QGraphicsScene(parent), QGraphicsScene (project),
project_(0), project_ (nullptr),
diagram_qet_version_ (-1), diagram_qet_version_ (-1),
draw_grid_ (true), draw_grid_ (true),
use_border_ (true), use_border_ (true),
@@ -55,6 +57,7 @@ Diagram::Diagram(QObject *parent) :
draw_colored_conductors_ (true), draw_colored_conductors_ (true),
read_only_ (false) read_only_ (false)
{ {
setProject(project);
qgi_manager_ = new QGIManager(this); qgi_manager_ = new QGIManager(this);
setBackgroundBrush(Qt::white); setBackgroundBrush(Qt::white);
conductor_setter_ = new QGraphicsLineItem(0, 0); conductor_setter_ = new QGraphicsLineItem(0, 0);
@@ -66,18 +69,12 @@ Diagram::Diagram(QObject *parent) :
conductor_setter_ -> setPen(t); conductor_setter_ -> setPen(t);
conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0))); conductor_setter_ -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
// initialise les objets gerant les deplacements //Init object for manage movement
elements_mover_ = new ElementsMover(); // deplacements d'elements/conducteurs/textes elements_mover_ = new ElementsMover();
element_texts_mover_ = new ElementTextsMover(); // deplacements d'ElementTextItem element_texts_mover_ = new ElementTextsMover();
connect( connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(titleChanged(const QString &)));
this, SLOT(setTitleBlockTemplate(const QString &))
);
connect(
&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),
this, SLOT(titleChanged(const QString &))
);
} }
/** /**
@@ -1203,19 +1200,25 @@ QETProject *Diagram::project() const {
/** /**
* @brief Diagram::setProject * @brief Diagram::setProject
* @param project: set parent project of this diagram or 0 if this diagram haven't got a parent project * Set parent project of this diagram, project also become the parent QObject of this diagram
* @param project new project
*/ */
void Diagram::setProject(QETProject *project) { void Diagram::setProject(QETProject *project)
if (project_) { {
if (project_ == project) return;
if (project_)
{
disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString))); disconnect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged())); disconnect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
} }
project_ = project; project_ = project;
if (project_) { setParent (project);
connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString))); connect (project_, SIGNAL(reportPropertiesChanged(QString)), this, SIGNAL(reportPropertiesChanged(QString)));
connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged())); connect (project_, SIGNAL(XRefPropertiesChanged()), this, SIGNAL(XRefPropertiesChanged()));
} }
}
/** /**
@return the folio number of this diagram within its parent project, or -1 @return the folio number of this diagram within its parent project, or -1

View File

@@ -47,14 +47,14 @@ class ElementTextsMover;
This class represents an electric diagram. It manages its various child This class represents an electric diagram. It manages its various child
elements, conductors and texts and handles their graphic rendering. elements, conductors and texts and handles their graphic rendering.
*/ */
class Diagram : public QGraphicsScene { class Diagram : public QGraphicsScene
{
Q_OBJECT Q_OBJECT
// constructors, destructor // constructors, destructor
public: public:
Diagram(QObject * = 0); Diagram(QETProject *project);
virtual ~Diagram(); virtual ~Diagram();
private: private:
Diagram(const Diagram &diagram); Diagram(const Diagram &diagram);

View File

@@ -24,17 +24,13 @@ qreal DiagramFolioList::colWidths[4] = {0.1, 0.55, 0.2, 0.15};
/** /**
* @brief DiagramFolioList::DiagramFolioList * @brief DiagramFolioList::DiagramFolioList
* Constructor * Constructor
* @param project QETproject *: The project from which this constructor was called. Important to setProject(). * @param project : The project of this diagram and also parent QObject
* @param parent parent QObject
*/ */
DiagramFolioList::DiagramFolioList( QETProject *project, QObject *parent) : Diagram(parent) { DiagramFolioList::DiagramFolioList( QETProject *project) :
if (project) { Diagram(project)
setProject(project); {
id = project -> getFolioSheetsQuantity(); id = project -> getFolioSheetsQuantity();
} }
else
id = 0;
}
/** /**
* @brief DiagramFolioList::~DiagramFolioList * @brief DiagramFolioList::~DiagramFolioList

View File

@@ -24,7 +24,7 @@
class DiagramFolioList : public Diagram class DiagramFolioList : public Diagram
{ {
public: public:
DiagramFolioList( QETProject *project = 0, QObject *parent = 0); DiagramFolioList(QETProject *project);
virtual ~DiagramFolioList(); virtual ~DiagramFolioList();
virtual QList<QLineF *> lines() const {return list_lines_;} virtual QList<QLineF *> lines() const {return list_lines_;}
virtual QList<QRectF *> rectangles() const {return list_rectangles_;} virtual QList<QRectF *> rectangles() const {return list_rectangles_;}

View File

@@ -902,7 +902,7 @@ Diagram *QETProject::addNewDiagram() {
if (isReadOnly()) return(0); if (isReadOnly()) return(0);
// cree un nouveau schema // cree un nouveau schema
Diagram *diagram = new Diagram(); Diagram *diagram = new Diagram(this);
// lui transmet les parametres par defaut // lui transmet les parametres par defaut
diagram -> border_and_titleblock.importBorder(defaultBorderProperties()); diagram -> border_and_titleblock.importBorder(defaultBorderProperties());
@@ -1120,8 +1120,7 @@ void QETProject::readDiagramsXml() {
dlgWaiting->setProgressBar(i+1); dlgWaiting->setProgressBar(i+1);
if (diagram_nodes.at(i).isElement()) { if (diagram_nodes.at(i).isElement()) {
QDomElement diagram_xml_element = diagram_nodes.at(i).toElement(); QDomElement diagram_xml_element = diagram_nodes.at(i).toElement();
Diagram *diagram = new Diagram(); Diagram *diagram = new Diagram(this);
diagram -> setProject(this);
bool diagram_loading = diagram -> initFromXml(diagram_xml_element); bool diagram_loading = diagram -> initFromXml(diagram_xml_element);
if (diagram_loading) { if (diagram_loading) {
dlgWaiting->setDetail( diagram->title() ); dlgWaiting->setDetail( diagram->title() );