mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
add class ElementProvider and build small ui for the properties of folio report element
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2672 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -936,6 +936,15 @@ QList<CustomElement *> Diagram::customElements() const {
|
|||||||
return(elements_list);
|
return(elements_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList <Element *> Diagram::elements() const {
|
||||||
|
QList<Element *> element_list;
|
||||||
|
foreach (QGraphicsItem *qgi, items()) {
|
||||||
|
if (Element *elmt = qgraphicsitem_cast<Element *>(qgi))
|
||||||
|
element_list <<elmt;
|
||||||
|
}
|
||||||
|
return (element_list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialise un deplacement d'elements, conducteurs et champs de texte sur le
|
Initialise un deplacement d'elements, conducteurs et champs de texte sur le
|
||||||
schema.
|
schema.
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
QList<CustomElement *> customElements() const;
|
QList<CustomElement *> customElements() const;
|
||||||
|
QList<Element *> elements() const;
|
||||||
QSet<DiagramTextItem *> selectedTexts() const;
|
QSet<DiagramTextItem *> selectedTexts() const;
|
||||||
QSet<ConductorTextItem *> selectedConductorTexts() const;
|
QSet<ConductorTextItem *> selectedConductorTexts() const;
|
||||||
QSet<Conductor *> selectedConductors() const;
|
QSet<Conductor *> selectedConductors() const;
|
||||||
|
|||||||
54
sources/elementprovider.cpp
Normal file
54
sources/elementprovider.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2013 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 "elementprovider.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementProvider::ElementProvider Constructor
|
||||||
|
* @param prj the project where we must find element
|
||||||
|
* @param diagram the digram to exclude from the search
|
||||||
|
*/
|
||||||
|
ElementProvider::ElementProvider(QETProject *prj, Diagram *diagram)
|
||||||
|
{
|
||||||
|
diag_list = prj->diagrams();
|
||||||
|
diag_list.removeOne(diagram);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementProvider::FreeElement
|
||||||
|
* Search and return the asked element corresponding with the given filter
|
||||||
|
* All returned element are free, ie element aren't connected with another element
|
||||||
|
* @param filter
|
||||||
|
* the filter for search element
|
||||||
|
* (the filter must be the enum linkerType in Element.h)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QList <Element *> ElementProvider::FreeElement(int filter) {
|
||||||
|
QList <Element *> free_elmt;
|
||||||
|
|
||||||
|
//serch in all diagram
|
||||||
|
foreach (Diagram *d, diag_list) {
|
||||||
|
//get all element in diagram d
|
||||||
|
QList <Element *> elmt_list;
|
||||||
|
elmt_list = d->elements();
|
||||||
|
foreach (Element *elmt, elmt_list) {
|
||||||
|
if (filter & elmt->linkType())
|
||||||
|
if (elmt->isFree()) free_elmt << elmt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (free_elmt);
|
||||||
|
}
|
||||||
41
sources/elementprovider.h
Normal file
41
sources/elementprovider.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2013 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 ELEMENTPROVIDER_H
|
||||||
|
#define ELEMENTPROVIDER_H
|
||||||
|
|
||||||
|
#include "qetproject.h"
|
||||||
|
#include "diagram.h"
|
||||||
|
#include "qetgraphicsitem/element.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
this class can search in the given diagram or project some kind of element
|
||||||
|
like 'folio report' or 'master' and return it.
|
||||||
|
We can get element element with specific status like 'free'.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ElementProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ElementProvider(QETProject *prj, Diagram *diagram=0);
|
||||||
|
QList <Element *> FreeElement(int filter);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList <Diagram *> diag_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ELEMENTPROVIDER_H
|
||||||
@@ -56,6 +56,7 @@ class Element : public QetGraphicsItem {
|
|||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
QPoint hotspot_coord;
|
QPoint hotspot_coord;
|
||||||
QPixmap preview;
|
QPixmap preview;
|
||||||
|
QList <Element *> connected_elements;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
@@ -79,6 +80,7 @@ class Element : public QetGraphicsItem {
|
|||||||
virtual int minTerminalsCount() const = 0;
|
virtual int minTerminalsCount() const = 0;
|
||||||
/// @return the maximum number of terminals for this element
|
/// @return the maximum number of terminals for this element
|
||||||
virtual int maxTerminalsCount() const = 0;
|
virtual int maxTerminalsCount() const = 0;
|
||||||
|
bool isFree () const;
|
||||||
/**
|
/**
|
||||||
Draw this element
|
Draw this element
|
||||||
*/
|
*/
|
||||||
@@ -131,6 +133,10 @@ class Element : public QetGraphicsItem {
|
|||||||
void updatePixmap();
|
void updatePixmap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool Element::isFree() const {
|
||||||
|
return (connected_elements.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Indicate whether this element allows internal connections, i.e. whether its
|
Indicate whether this element allows internal connections, i.e. whether its
|
||||||
terminals can be linked together using a conductor.
|
terminals can be linked together using a conductor.
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ void elementpropertieswidget::buildInterface() {
|
|||||||
case Element::simple:
|
case Element::simple:
|
||||||
break;
|
break;
|
||||||
case Element::report:
|
case Element::report:
|
||||||
w = new QComboBox(this);
|
frp_ = new FolioReportProperties(element_, this);
|
||||||
tab_ -> addTab(w, tr("Report de folio"));
|
tab_ -> addTab(frp_, tr("Report de folio"));
|
||||||
break;
|
break;
|
||||||
case Element::master:
|
case Element::master:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <qetgraphicsitem/element.h>
|
#include <qetgraphicsitem/element.h>
|
||||||
#include <diagram.h>
|
#include <diagram.h>
|
||||||
|
#include <folioreportproperties.h>
|
||||||
|
|
||||||
class elementpropertieswidget : public QDialog
|
class elementpropertieswidget : public QDialog
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,7 @@ class elementpropertieswidget : public QDialog
|
|||||||
void editElement ();
|
void editElement ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *w; ///this widget is only for test
|
FolioReportProperties *frp_;
|
||||||
QDialogButtonBox *dbb;
|
QDialogButtonBox *dbb;
|
||||||
Element *element_;
|
Element *element_;
|
||||||
Diagram *diagram_;
|
Diagram *diagram_;
|
||||||
|
|||||||
34
sources/ui/folioreportproperties.cpp
Normal file
34
sources/ui/folioreportproperties.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include "folioreportproperties.h"
|
||||||
|
#include "ui_folioreportproperties.h"
|
||||||
|
|
||||||
|
#include <diagramposition.h>
|
||||||
|
#include <elementprovider.h>
|
||||||
|
|
||||||
|
FolioReportProperties::FolioReportProperties(Element *elmt, QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
element_(elmt),
|
||||||
|
ui(new Ui::FolioReportProperties)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ElementProvider ep(element_->diagram()->project(), element_->diagram());
|
||||||
|
QList <Element *> elmt_list = ep.FreeElement(Element::report);
|
||||||
|
|
||||||
|
foreach (Element *elmt, elmt_list) {
|
||||||
|
if (elmt != element_) {
|
||||||
|
QString button_text;
|
||||||
|
button_text += elmt->name();
|
||||||
|
button_text += QString(tr(" Folio\240: %1, ")).arg(elmt->diagram()->folioIndex() + 1);
|
||||||
|
button_text += QString(tr("Position\240: %1")).arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
|
||||||
|
|
||||||
|
QRadioButton *rb = new QRadioButton(button_text , this);
|
||||||
|
ui->available_report_layout->addWidget(rb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->available_report_layout->addStretch();
|
||||||
|
}
|
||||||
|
|
||||||
|
FolioReportProperties::~FolioReportProperties()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
24
sources/ui/folioreportproperties.h
Normal file
24
sources/ui/folioreportproperties.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef FOLIOREPORTPROPERTIES_H
|
||||||
|
#define FOLIOREPORTPROPERTIES_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <qetgraphicsitem/element.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class FolioReportProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FolioReportProperties : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FolioReportProperties(Element *elmt, QWidget *parent = 0);
|
||||||
|
~FolioReportProperties();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Element *element_;
|
||||||
|
Ui::FolioReportProperties *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FOLIOREPORTPROPERTIES_H
|
||||||
77
sources/ui/folioreportproperties.ui
Normal file
77
sources/ui/folioreportproperties.ui
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>FolioReportProperties</class>
|
||||||
|
<widget class="QWidget" name="FolioReportProperties">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="Report_gb">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Report de folio pouvant être liée"/>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string extracomment="C'est ici que vous pouvez spécifier à quel autre report de folio doit être liée celui ci "/>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Report de folio disponible :</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="_2">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scroll_area">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>370</width>
|
||||||
|
<height>258</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="available_report_layout">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user