[qet] [2921] Replace the class folioReportProperties by the class linkSingleElementWidget . |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2921
Author: blacksun
Date: 2014-03-12 10:32:56 +0100 (Wed, 12 Mar 2014)
Log Message:
-----------
Replace the class folioReportProperties by the class linkSingleElementWidget.
The new class does the same thing but is more flexible, this class is used by report and slave element
to find element to be linked and/or unlink an already linked element.
Modified Paths:
--------------
trunk/qelectrotech.pro
trunk/sources/diagramcommands.cpp
trunk/sources/diagramcommands.h
trunk/sources/elementprovider.cpp
trunk/sources/elementprovider.h
trunk/sources/ui/elementpropertieswidget.cpp
trunk/sources/ui/elementpropertieswidget.h
Added Paths:
-----------
trunk/sources/ui/elementselectorwidget.cpp
trunk/sources/ui/elementselectorwidget.h
trunk/sources/ui/elementselectorwidget.ui
trunk/sources/ui/linksingleelementwidget.cpp
trunk/sources/ui/linksingleelementwidget.h
trunk/sources/ui/linksingleelementwidget.ui
Removed Paths:
-------------
trunk/sources/ui/folioreportproperties.cpp
trunk/sources/ui/folioreportproperties.h
trunk/sources/ui/folioreportproperties.ui
Modified: trunk/qelectrotech.pro
===================================================================
--- trunk/qelectrotech.pro 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/qelectrotech.pro 2014-03-12 09:32:56 UTC (rev 2921)
@@ -61,10 +61,11 @@
TEMPLATE = app
DEPENDPATH += .
-INCLUDEPATH += sources sources/editor sources/titleblock
+INCLUDEPATH += sources sources/editor sources/titleblock sources/ui sources/qetgraphicsitem sources/richtext sources/factory
# Fichiers sources
HEADERS += sources/*.h sources/ui/*.h sources/editor/*.h sources/titleblock/*.h sources/richtext/*.h sources/qetgraphicsitem/*.h sources/factory/*.cpp
+
SOURCES += sources/*.cpp sources/editor/*.cpp sources/titleblock/*.cpp sources/richtext/*.cpp sources/ui/*.cpp sources/qetgraphicsitem/*.cpp sources/factory/*.cpp
# Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
@@ -80,7 +81,9 @@
QT += xml svg network sql
# UI DESIGNER FILES AND GENERATION SOURCES FILES
-FORMS += sources/richtext/addlinkdialog.ui sources/ui/*.ui
+FORMS += sources/richtext/addlinkdialog.ui sources/ui/*.ui \
+ sources/ui/slavepropertieswidget.ui \
+ sources/ui/linksingleelementwidget.ui
UI_SOURCES_DIR = sources/ui/
UI_HEADERS_DIR = sources/ui/
Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/diagramcommands.cpp 2014-03-12 09:32:56 UTC (rev 2921)
@@ -1250,7 +1250,6 @@
QUndoCommand(parent),
diagram_(elmt1->diagram()),
element_(elmt1),
- previous_report(0),
first_redo(true)
{
elmt_list << elmt2;
@@ -1258,12 +1257,12 @@
elmt2->linkType() & Element::AllReport) {
setText(QObject::tr("Lier deux reports de folio",
"title for undo LinkElementsCommand if two elements are folio report"));
- if(!elmt1->isFree())
- previous_report = elmt1->linkedElements().first();
}
- else if (element_->linkType() & Element::Master)
+ else if (element_->linkType() & (Element::Master|Element::Slave))
setText(QObject::tr("Editer les r\351f\351rence crois\351", "edite the cross reference"));
else setText(QObject::tr("Lier deux éléments"));
+
+ previous_linked = elmt1->linkedElements();
}
LinkElementsCommand::LinkElementsCommand(Element *elmt1, QList<Element *> &elmtList, QUndoCommand *parent) :
@@ -1271,12 +1270,12 @@
diagram_(elmt1->diagram()),
element_(elmt1),
elmt_list(elmtList),
- previous_report(0),
first_redo(true)
{
- if (element_->linkType() & Element::Master)
+ if (element_->linkType() & (Element::Master|Element::Slave))
setText(QObject::tr("Editer les r\351f\351rence crois\351"));
else setText(QObject::tr("Lier deux éléments"));
+ previous_linked = elmt1->linkedElements();
}
/**
@@ -1295,8 +1294,9 @@
foreach (Element *elmt, elmt_list)
element_->unlinkElement(elmt);
- if (previous_report)
- element_->linkToElement(previous_report);
+ foreach (Element *elmt, previous_linked)
+ element_->linkToElement(elmt);
+
QUndoCommand::undo();
}
Modified: trunk/sources/diagramcommands.h
===================================================================
--- trunk/sources/diagramcommands.h 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/diagramcommands.h 2014-03-12 09:32:56 UTC (rev 2921)
@@ -648,8 +648,9 @@
private:
//attributes
Diagram *diagram_;
- Element *element_, *previous_report;
+ Element *element_;
QList <Element *> elmt_list;
+ QList <Element *> previous_linked;
bool first_redo;
};
Modified: trunk/sources/elementprovider.cpp
===================================================================
--- trunk/sources/elementprovider.cpp 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/elementprovider.cpp 2014-03-12 09:32:56 UTC (rev 2921)
@@ -21,7 +21,7 @@
/**
* @brief ElementProvider::ElementProvider Constructor
* @param prj the project where we must find element
- * @param diagram the digram to exclude from the search
+ * @param diagram the diagram to exclude from the search
*/
ElementProvider::ElementProvider(QETProject *prj, Diagram *diagram)
{
@@ -30,6 +30,14 @@
}
/**
+ * @brief ElementProvider::ElementProvider Constructor
+ * @param diag Diagram to search
+ */
+ElementProvider::ElementProvider(Diagram *diag) {
+ diag_list << diag;
+}
+
+/**
* @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
@@ -72,3 +80,26 @@
}
return found_element;
}
+
+/**
+ * @brief ElementProvider::find
+ * Search and return the asked element corresponding with the given filter
+ * @param filter
+ * the filter for search element
+ * (You can find all filter with the #define in Element.h)
+ */
+QList <Element *> ElementProvider::find(const int filter) const {
+ QList <Element *> 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())
+ elmt_ << elmt;
+ }
+ }
+ return (elmt_);
+}
Modified: trunk/sources/elementprovider.h
===================================================================
--- trunk/sources/elementprovider.h 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/elementprovider.h 2014-03-12 09:32:56 UTC (rev 2921)
@@ -32,8 +32,10 @@
{
public:
ElementProvider(QETProject *prj, Diagram *diagram=0);
+ ElementProvider(Diagram *diag);
QList <Element *> freeElement(const int filter) const;
QList <Element *> fromUuids(QList <QUuid>) const;
+ QList <Element *> find(const int filter) const;
private:
QList <Diagram *> diag_list;
Modified: trunk/sources/ui/elementpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/elementpropertieswidget.cpp 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/ui/elementpropertieswidget.cpp 2014-03-12 09:32:56 UTC (rev 2921)
@@ -16,9 +16,9 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementpropertieswidget.h"
-#include <qetgraphicsitem/ghostelement.h>
-#include <qeticons.h>
-#include <diagramposition.h>
+#include "qetgraphicsitem/ghostelement.h"
+#include "qeticons.h"
+#include "diagramposition.h"
/**
* @brief elementpropertieswidget::elementpropertieswidget
@@ -31,9 +31,9 @@
element_ (elmt),
diagram_ (elmt->diagram())
{
- frp_ = 0;
eiw_ = 0;
mpw_ = 0;
+ lsew_ = 0;
buildInterface();
}
@@ -114,12 +114,12 @@
tab_ -> addTab(eiw_, tr("Information"));
break;
case Element::NextReport:
- frp_ = new FolioReportProperties(element_, this);
- tab_ -> addTab(frp_, tr("Report de folio"));
+ lsew_ = new LinkSingleElementWidget(element_, this);
+ tab_ -> addTab(lsew_, tr("Report de folio"));
break;
case Element::PreviousReport:
- frp_ = new FolioReportProperties(element_, this);
- tab_ -> addTab(frp_, tr("Report de folio"));
+ lsew_ = new LinkSingleElementWidget(element_, this);
+ tab_ -> addTab(lsew_, tr("Report de folio"));
break;
case Element::Master:
mpw_ = new MasterPropertiesWidget(element_, this);
@@ -128,6 +128,8 @@
tab_ -> addTab(eiw_, tr("Information"));
break;
case Element::Slave:
+ lsew_ = new LinkSingleElementWidget(element_, this);
+ tab_ -> addTab(lsew_, tr("R\351f\351rence crois\351e (esclave)"));
break;
case Element::Bornier:
break;
@@ -161,9 +163,9 @@
if (mpw_) mpw_->reset();
break;
case QDialogButtonBox::ApplyRole:
- if (frp_) frp_->Apply(); //folio report widget
if (eiw_) eiw_->apply(); //element information widget
if (mpw_) mpw_->apply(); //master property widget
+ if (lsew_) lsew_->apply(); //link sigle element widget
this->accept();
case QDialogButtonBox::RejectRole:
this->reject();
Modified: trunk/sources/ui/elementpropertieswidget.h
===================================================================
--- trunk/sources/ui/elementpropertieswidget.h 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/ui/elementpropertieswidget.h 2014-03-12 09:32:56 UTC (rev 2921)
@@ -19,11 +19,11 @@
#define ELEMENTPROPERTIESWIDGET_H
#include <QtGui>
-#include <qetgraphicsitem/element.h>
-#include <diagram.h>
-#include <folioreportproperties.h>
-#include <elementinfowidget.h>
-#include <masterpropertieswidget.h>
+#include "qetgraphicsitem/element.h"
+#include "diagram.h"
+#include "elementinfowidget.h"
+#include "masterpropertieswidget.h"
+#include "linksingleelementwidget.h"
class elementpropertieswidget : public QDialog
{
@@ -47,9 +47,9 @@
void editElement ();
private:
- FolioReportProperties *frp_;
ElementInfoWidget *eiw_;
MasterPropertiesWidget *mpw_;
+ LinkSingleElementWidget *lsew_;
QDialogButtonBox *dbb;
Element *element_;
Diagram *diagram_;
Added: trunk/sources/ui/elementselectorwidget.cpp
===================================================================
--- trunk/sources/ui/elementselectorwidget.cpp (rev 0)
+++ trunk/sources/ui/elementselectorwidget.cpp 2014-03-12 09:32:56 UTC (rev 2921)
@@ -0,0 +1,116 @@
+/*
+ Copyright 2006-2014 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 "elementselectorwidget.h"
+#include "ui_elementselectorwidget.h"
+#include "diagramposition.h"
+#include "qeticons.h"
+
+/**
+ * @brief ElementSelectorWidget::ElementSelectorWidget
+ * Default constructor
+ * @param elmt_list
+ * List of element to be displayed by the selector
+ * @param parent
+ * Parent widget
+ */
+ElementSelectorWidget::ElementSelectorWidget(QList <Element *> elmt_list, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::ElementSelectorWidget),
+ elements_list(elmt_list),
+ selected_element(0),
+ showed_element(0)
+{
+ ui->setupUi(this);
+ buildInterface();
+}
+
+/**
+ * @brief ElementSelectorWidget::~ElementSelectorWidget
+ * Default destructor
+ */
+ElementSelectorWidget::~ElementSelectorWidget()
+{
+ if (showed_element) showed_element->setHighlighted(false);
+ delete ui;
+}
+
+/**
+ * @brief ElementSelectorWidget::showElement
+ * Show the element given by parametre
+ * @param elmt
+ */
+void ElementSelectorWidget::showElement(Element *elmt) {
+ if (showed_element) showed_element->setHighlighted(false);
+ elmt->diagram()->showMe();
+ elmt->setHighlighted(true);
+ showed_element = elmt;
+}
+
+/**
+ * @brief ElementSelectorWidget::buildInterface
+ * Build interface of this widget (fill all available element)
+ */
+void ElementSelectorWidget::buildInterface() {
+ //Setup the signal mapper
+ int map_id = 0; //this int is used to map the signal
+ sm_ = new QSignalMapper(this);
+ connect(sm_, SIGNAL(mapped(int)), this, SLOT(setSelectedElement(int)));
+ sm_show_ = new QSignalMapper(this);
+ connect(sm_show_, SIGNAL(mapped(int)), this, SLOT(showElementFromList(int)));
+
+ //Build the list
+ foreach (Element *elmt, elements_list) {
+ //label for the button
+ QString button_text;
+ QString title = elmt->diagram()->title();
+ if (title.isEmpty()) title = tr("Sans titre");
+ button_text += QString(tr("Folio\240 %1 (%2), position %3.")).arg(elmt->diagram()->folioIndex() + 1)
+ .arg(title)
+ .arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
+
+ //add the button himself
+ QHBoxLayout *hl = new QHBoxLayout();
+ QRadioButton *rb = new QRadioButton(button_text , this);
+ QPushButton *pb = new QPushButton(QET::Icons::ZoomDraw,"", this);
+ pb->setToolTip(tr("Voir l'\351l\351ment"));
+ hl->addWidget(rb);
+ hl->addStretch();
+ hl->addWidget(pb);
+ ui->scroll_layout_->addLayout(hl);
+
+ //map the radio button signal
+ connect(rb, SIGNAL(clicked()), sm_, SLOT(map()));
+ sm_ -> setMapping(rb, map_id);
+ //map the push button show diagram
+ connect(pb, SIGNAL(clicked()), sm_show_, SLOT(map()));
+ sm_show_->setMapping(pb, map_id);
+
+ map_id++; //increase the map_id for next button.
+ }
+ ui->scroll_layout_->addStretch();
+}
+
+/**
+ * @brief ElementSelectorWidget::showElementFromList
+ * Show the element at the position i in @elements_list
+ * @param i
+ */
+void ElementSelectorWidget::showElementFromList(const int i) {
+ if (elements_list.size() >= i)
+ showElement(elements_list.at(i));
+}
Added: trunk/sources/ui/elementselectorwidget.h
===================================================================
--- trunk/sources/ui/elementselectorwidget.h (rev 0)
+++ trunk/sources/ui/elementselectorwidget.h 2014-03-12 09:32:56 UTC (rev 2921)
@@ -0,0 +1,61 @@
+/*
+ Copyright 2006-2014 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 ELEMENTSELECTORWIDGET_H
+#define ELEMENTSELECTORWIDGET_H
+
+#include <QWidget>
+#include "qetgraphicsitem/element.h"
+
+namespace Ui {
+ class ElementSelectorWidget;
+}
+
+/**
+ * @brief The ElementSelectorWidget class
+ * This class provide a widget with a list of element.
+ * User can select an element in the list and higligth it.
+ * For know what element is selected, call selectedElement.
+ */
+class ElementSelectorWidget : public QWidget
+{
+ Q_OBJECT
+
+ ///Methods
+ public:
+ explicit ElementSelectorWidget(QList <Element *> elmt_list, QWidget *parent = 0);
+ ~ElementSelectorWidget();
+ Element * selectedElement () const{return selected_element;}
+ void showElement(Element *elmt);
+
+ private:
+ void buildInterface();
+
+ private slots:
+ void setSelectedElement(const int i) {selected_element = elements_list.at(i);}
+ void showElementFromList (const int i);
+
+
+ ///Attributes
+ private:
+ Ui::ElementSelectorWidget *ui;
+ QList <Element *> elements_list;
+ QSignalMapper *sm_, *sm_show_;
+ Element *selected_element, *showed_element;
+};
+
+#endif // ELEMENTSELECTORWIDGET_H
Added: trunk/sources/ui/elementselectorwidget.ui
===================================================================
--- trunk/sources/ui/elementselectorwidget.ui (rev 0)
+++ trunk/sources/ui/elementselectorwidget.ui 2014-03-12 09:32:56 UTC (rev 2921)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ElementSelectorWidget</class>
+ <widget class="QWidget" name="ElementSelectorWidget">
+ <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="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>380</width>
+ <height>280</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="scroll_layout_"/>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Deleted: trunk/sources/ui/folioreportproperties.cpp
===================================================================
--- trunk/sources/ui/folioreportproperties.cpp 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/ui/folioreportproperties.cpp 2014-03-12 09:32:56 UTC (rev 2921)
@@ -1,175 +0,0 @@
-/*
- Copyright 2006-2014 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 "folioreportproperties.h"
-#include "ui_folioreportproperties.h"
-
-#include <diagramposition.h>
-#include <elementprovider.h>
-#include <qetgraphicsitem/elementtextitem.h>
-#include <diagramcommands.h>
-#include "qeticons.h"
-
-/**
- * @brief FolioReportProperties::FolioReportProperties : Construcor
- * @param elmt : The edited element
- * @param parent : Parent widget
- */
-FolioReportProperties::FolioReportProperties(Element *elmt, QWidget *parent) :
- QWidget(parent),
- element_(elmt),
- element_to_link(0),
- ui(new Ui::FolioReportProperties)
-{
- ui->setupUi(this);
- unlink = false;
- if(element_->isFree()) {
- buildRadioList();
- ui->button_linked->setDisabled(true);
- }
- else buildUnlinkButton();
-}
-
-/**
- * @brief FolioReportProperties::~FolioReportProperties : Destructor
- */
-FolioReportProperties::~FolioReportProperties()
-{
- delete ui;
-}
-
-/**
- * @brief FolioReportProperties::BuildRadioList : build the radio list for each available folio report
- */
-void FolioReportProperties::buildRadioList() {
- sm_ = new QSignalMapper(this);
- connect(sm_, SIGNAL(mapped(int)), this, SLOT(linkToElement(int)));
- sm_show_ = new QSignalMapper(this);
- connect(sm_show_, SIGNAL(mapped(int)), this, SLOT(showElementFromList(int)));
-
- //Research the invert report of @element_
- int rep = element_->linkType() == Element::NextReport? Element::PreviousReport : Element::NextReport;
- ElementProvider ep(element_->diagram()->project());
- QList <Element *> elmt_list = ep.freeElement(rep);
-
- foreach (Element *elmt, elmt_list) {
- if (elmt != element_) {
- //label for the button
- QString button_text;
- QString title = elmt->diagram()->title();
- if (title.isEmpty()) title = tr("Sans titre");
- button_text += QString(tr("Folio\240 %1 (%2), position %3.")).arg(elmt->diagram()->folioIndex() + 1)
- .arg(title)
- .arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
-
- //button himself
- QHBoxLayout *hl = new QHBoxLayout();
- QRadioButton *rb = new QRadioButton(button_text , this);
- QPushButton *pb = new QPushButton(QET::Icons::ZoomDraw,"",this);
- hl->addWidget(rb);
- hl->addStretch();
- hl->addWidget(pb);
- ui->available_report_layout->addLayout(hl);
- element_list << elmt;
- //map the radio button signal
- connect(rb, SIGNAL(clicked()), sm_, SLOT(map()));
- sm_ -> setMapping(rb, element_list.size()-1);
- //map the push button show diagram
- connect(pb, SIGNAL(clicked()), sm_show_, SLOT(map()));
- sm_show_->setMapping(pb, element_list.size()-1);
- }
- }
- ui->available_report_layout->addStretch();
-}
-
-/**
- * @brief FolioReportProperties::buildUnlinkButton
- *build button for ask user if want to unlink this element
- */
-void FolioReportProperties::buildUnlinkButton() {
- unlink_widget = new QWidget(this);
- QHBoxLayout *unlink_layout = new QHBoxLayout(unlink_widget);
- QLabel *lb = new QLabel(tr("Ce report est d\351j\340 li\351."), unlink_widget);
- QPushButton *pb = new QPushButton(tr("D\351lier"), unlink_widget);
- connect(pb, SIGNAL(clicked()), this, SLOT(unlinkClicked()));
- unlink_layout->addWidget(lb);
- unlink_layout->addStretch();
- unlink_layout->addWidget(pb);
- ui->v_main_layout->insertWidget(0, unlink_widget);
-}
-
-/**
- * @brief FolioReportProperties::Apply
- * Apply the new properties for this folio report
- */
-void FolioReportProperties::Apply() {
- if (unlink && !element_to_link)
- element_->diagram()->undoStack().push(new unlinkElementsCommand(element_));
- else if (element_to_link)
- element_->diagram()->undoStack().push(new LinkElementsCommand(element_, element_to_link));
-}
-
-/**
- * @brief FolioReportProperties::unlinkClicked
- *this slot remove unlink_layout and call buildRadioList
- */
-void FolioReportProperties::unlinkClicked() {
- ui->v_main_layout->removeWidget(unlink_widget);
- delete unlink_widget;
- unlink = true;
- buildRadioList();
-}
-
-/**
- * @brief FolioReportProperties::showElement
- * Show the required element
- * @param elmt: element to be displayed
- */
-void FolioReportProperties::showElement(Element *elmt) {
- QList <Element *> elmt_list = element_list;
- elmt_list << element_->linkedElements() << element_;
- foreach (Element *elmt, elmt_list) elmt->setSelected(false);
- elmt->diagram()->showMe();
- elmt->setSelected(true);
-}
-
-/**
- * @brief FolioReportProperties::showElementFromList
- * Show element at the position @i from @element_list
- * @param i position of element to be displayed
- */
-void FolioReportProperties::showElementFromList(const int i) {
- if (element_list.size() > i)
- showElement(element_list.at(i));
-}
-
-/**
- * @brief FolioReportProperties::on_button_this_clicked
- * Action when push button "this report" is clicked
- */
-void FolioReportProperties::on_button_this_clicked() {
- showElement(element_);
-}
-
-/**
- * @brief FolioReportProperties::on_button_linked_clicked
- * Action when push button "linked report" is clicked
- */
-void FolioReportProperties::on_button_linked_clicked() {
- if (element_->isFree()) return;
- showElement(element_->linkedElements().first());
-}
Deleted: trunk/sources/ui/folioreportproperties.h
===================================================================
--- trunk/sources/ui/folioreportproperties.h 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/ui/folioreportproperties.h 2014-03-12 09:32:56 UTC (rev 2921)
@@ -1,62 +0,0 @@
-/*
- Copyright 2006-2014 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 FOLIOREPORTPROPERTIES_H
-#define FOLIOREPORTPROPERTIES_H
-
-#include <QWidget>
-#include <qetgraphicsitem/element.h>
-
-namespace Ui {
- class FolioReportProperties;
-}
-
-/**
- * @brief The FolioReportProperties class
- * This class is a widget for make link between two reports element.
- * This class embendded the undo/redo command when apply new connection.
- */
-class FolioReportProperties : public QWidget
-{
- Q_OBJECT
-
- public:
- explicit FolioReportProperties(Element *elmt, QWidget *parent = 0);
- ~FolioReportProperties();
- void Apply();
-
- private slots:
- void linkToElement(const int i) {element_to_link = element_list.at(i);}
- void unlinkClicked();
- void showElement(Element *elmt);
- void showElementFromList (const int i);
- void on_button_this_clicked();
- void on_button_linked_clicked();
-
- private:
- void buildRadioList();
- void buildUnlinkButton();
-
- Element *element_, *element_to_link;
- QList <Element *> element_list;
- Ui::FolioReportProperties *ui;
- QSignalMapper *sm_, *sm_show_;
- QWidget *unlink_widget;
- bool unlink;
-};
-
-#endif // FOLIOREPORTPROPERTIES_H
Deleted: trunk/sources/ui/folioreportproperties.ui
===================================================================
--- trunk/sources/ui/folioreportproperties.ui 2014-03-10 14:12:05 UTC (rev 2920)
+++ trunk/sources/ui/folioreportproperties.ui 2014-03-12 09:32:56 UTC (rev 2921)
@@ -1,101 +0,0 @@
-<?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">
- <property name="margin">
- <number>9</number>
- </property>
- <item>
- <layout class="QVBoxLayout" name="v_main_layout">
- <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>224</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="available_report_layout">
- <property name="sizeConstraint">
- <enum>QLayout::SetMinimumSize</enum>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QPushButton" name="button_this">
- <property name="text">
- <string>Voir ce report</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="button_linked">
- <property name="text">
- <string>Voir le report lié</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
Added: trunk/sources/ui/linksingleelementwidget.cpp
===================================================================
--- trunk/sources/ui/linksingleelementwidget.cpp (rev 0)
+++ trunk/sources/ui/linksingleelementwidget.cpp 2014-03-12 09:32:56 UTC (rev 2921)
@@ -0,0 +1,194 @@
+/*
+ Copyright 2006-2014 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 "linksingleelementwidget.h"
+#include "ui_linksingleelementwidget.h"
+#include "diagram.h"
+#include "element.h"
+#include "elementprovider.h"
+#include "diagramcommands.h"
+
+/**
+ * @brief LinkSingleElementWidget::LinkSingleElementWidget
+ * Default constructor
+ * @param elmt
+ * the edited element
+ * @param parent
+ * the parent widget
+ */
+LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::LinkSingleElementWidget),
+ element_(elmt),
+ esw_(0),
+ diagram_list(element_->diagram()->project()->diagrams()),
+ unlink_widget(0),
+ unlink_(false)
+{
+ ui->setupUi(this);
+
+ if (elmt->linkType() & Element::Slave)
+ filter_ = Element::Master;
+ else if (elmt->linkType() & Element::AllReport)
+ filter_ = elmt->linkType() == Element::NextReport? Element::PreviousReport : Element::NextReport;
+ else
+ filter_ = Element::Simple;
+
+ buildInterface();
+ connect(ui->folio_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(reBuildList()));
+}
+
+/**
+ * @brief LinkSingleElementWidget::~LinkSingleElementWidget
+ * Default destructor
+ */
+LinkSingleElementWidget::~LinkSingleElementWidget()
+{
+ delete ui;
+}
+
+/**
+ * @brief LinkSingleElementWidget::apply
+ * Apply the new property of the edited element
+ */
+void LinkSingleElementWidget::apply() {
+ if (esw_->selectedElement())
+ element_->diagram()->undoStack().push(new LinkElementsCommand(element_, esw_->selectedElement()));
+ else if (unlink_)
+ element_->diagram()->undoStack().push(new unlinkElementsCommand(element_));
+}
+
+/**
+ * @brief LinkSingleElementWidget::buildInterface
+ * Build the interface of this widget
+ */
+void LinkSingleElementWidget::buildInterface() {
+ ui->folio_combo_box->addItem(tr("Tous"));
+
+ //Fill the combo box for filter the result by folio
+ foreach (Diagram *d, diagram_list) {
+ QString title = d->title();
+ if (title.isEmpty()) title = tr("Sans titre");
+ title.prepend(QString::number(d->folioIndex() + 1) + " ");
+ ui->folio_combo_box->addItem(title);
+ }
+
+ //Element is free build list
+ if(element_->isFree()) {
+ buildList();
+ ui->button_linked->setDisabled(true);
+ }
+ //Element isn't free build an empty list and add 'unlink' button
+ else {
+ buildUnlinkButton();
+ QList <Element *> elmt_list;
+ esw_ = new ElementSelectorWidget(elmt_list, this);
+ ui->content_layout->addWidget(esw_);
+ }
+}
+
+/**
+ * @brief LinkSingleElementWidget::buildList
+ * Build the element list of this widget,
+ * the list is fill with the element find in the
+ * required folio (folio selected with the combo box)
+ */
+void LinkSingleElementWidget::buildList() {
+ QList <Element *> elmt_list;
+ int i = ui->folio_combo_box->currentIndex();
+
+ //find in all diagram of this project
+ if (i == 0) {
+ ElementProvider ep(element_->diagram()->project());
+ if (filter_ & Element::AllReport)
+ elmt_list = ep.freeElement(filter_);
+ else
+ elmt_list = ep.find(filter_);
+ }
+ //find in single diagram
+ else {
+ ElementProvider ep (diagram_list.at(i-1));
+ if (filter_ & Element::AllReport)
+ elmt_list = ep.freeElement(filter_);
+ else
+ elmt_list = ep.find(filter_);
+ }
+
+ //If element is linked, remove is parent from the list
+ if(!element_->isFree()) elmt_list.removeAll(element_->linkedElements().first());
+
+ esw_ = new ElementSelectorWidget(elmt_list, this);
+ ui->content_layout->addWidget(esw_);
+}
+
+/**
+ * @brief LinkSingleElementWidget::buildUnlinkButton
+ * Build a widget with button 'unlink' if the edited
+ * element is already linked with a master element
+ */
+void LinkSingleElementWidget::buildUnlinkButton() {
+ unlink_widget = new QWidget(this);
+ QHBoxLayout *unlink_layout = new QHBoxLayout(unlink_widget);
+ QLabel *lb = new QLabel(tr("Cet \351l\351ment est d\351j\340 li\351."), unlink_widget);
+ QPushButton *pb = new QPushButton(tr("D\351lier"), unlink_widget);
+ connect(pb, SIGNAL(clicked()), this, SLOT(unlinkClicked()));
+ unlink_layout->addWidget(lb);
+ unlink_layout->addStretch();
+ unlink_layout->addWidget(pb);
+ ui->main_layout->insertWidget(0, unlink_widget);
+}
+
+/**
+ * @brief LinkSingleElementWidget::reBuildList
+ * Rebuild the list of element
+ */
+void LinkSingleElementWidget::reBuildList() {
+ if (element_->isFree() || unlink_) {
+ ui->content_layout->removeWidget(esw_);
+ delete esw_;
+ buildList();
+ }
+}
+
+/**
+ * @brief LinkSingleElementWidget::unlinkClicked
+ * Action when 'unlink' button is clicked
+ */
+void LinkSingleElementWidget::unlinkClicked() {
+ ui->main_layout->removeWidget(unlink_widget);
+ delete unlink_widget;
+ unlink_widget = 0;
+ unlink_ = true;
+ reBuildList();
+}
+
+/**
+ * @brief FolioReportProperties::on_button_this_clicked
+ * Action when push button "this report" is clicked
+ */
+void LinkSingleElementWidget::on_button_this_clicked() {
+ esw_->showElement(element_);
+}
+
+/**
+ * @brief FolioReportProperties::on_button_linked_clicked
+ * Action when push button "linked report" is clicked
+ */
+void LinkSingleElementWidget::on_button_linked_clicked() {
+ if (element_->isFree()) return;
+ esw_->showElement(element_->linkedElements().first());
+}
Added: trunk/sources/ui/linksingleelementwidget.h
===================================================================
--- trunk/sources/ui/linksingleelementwidget.h (rev 0)
+++ trunk/sources/ui/linksingleelementwidget.h 2014-03-12 09:32:56 UTC (rev 2921)
@@ -0,0 +1,73 @@
+/*
+ Copyright 2006-2014 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 LINKSINGLEELEMENTWIDGET_H
+#define LINKSINGLEELEMENTWIDGET_H
+
+#include <QWidget>
+#include "elementselectorwidget.h"
+
+class Element;
+class Diagram;
+
+namespace Ui {
+ class LinkSingleElementWidget;
+}
+
+/**
+* @brief The LinkSingleElementWidget class
+ * this class provide a widget to select an element to be linked
+ * to the element given in the constructor.
+ * The element given in constructor must be linked with only one other element (like report or slave element).
+ * This widget detect automaticaly the kind of element given in the constructor and
+ * search all element that can be linked with it.
+ * If the element is already linked, the widget ask user to unlink.
+ * This widget embedded the diagram command for undo/redo the action
+ */
+class LinkSingleElementWidget : public QWidget
+{
+ Q_OBJECT
+
+ ///Methods
+ public:
+ explicit LinkSingleElementWidget(Element *elmt, QWidget *parent = 0);
+ ~LinkSingleElementWidget();
+ void apply();
+
+ private:
+ void buildInterface();
+ void buildList();
+ void buildUnlinkButton();
+
+ private slots:
+ void reBuildList();
+ void unlinkClicked();
+ void on_button_this_clicked();
+ void on_button_linked_clicked();
+
+ ///Attributes
+ private:
+ Ui::LinkSingleElementWidget *ui;
+ Element *element_;
+ ElementSelectorWidget *esw_;
+ QList <Diagram *> diagram_list;
+ QWidget *unlink_widget;
+ bool unlink_;
+ Element::kind filter_;
+};
+
+#endif // LINKSINGLEELEMENTWIDGET_H
Added: trunk/sources/ui/linksingleelementwidget.ui
===================================================================
--- trunk/sources/ui/linksingleelementwidget.ui (rev 0)
+++ trunk/sources/ui/linksingleelementwidget.ui 2014-03-12 09:32:56 UTC (rev 2921)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LinkSingleElementWidget</class>
+ <widget class="QWidget" name="LinkSingleElementWidget">
+ <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="QVBoxLayout" name="main_layout">
+ <item>
+ <layout class="QHBoxLayout" name="header_layout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Rechercher dans le folio :</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="folio_combo_box"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="content_layout"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="button_this">
+ <property name="text">
+ <string>Voir cet élément</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="button_linked">
+ <property name="text">
+ <string>Voir l'élément lié</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>