mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
make new element properties dialog (first step for the new dialog)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2646 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
9b1052484e
commit
6424ce4819
@ -199,6 +199,10 @@ class Diagram : public QGraphicsScene {
|
||||
void readOnlyChanged(bool);
|
||||
void usedTitleBlockTemplateChanged(const QString &);
|
||||
void diagramTitleChanged(Diagram *, const QString &);
|
||||
/// Signal emitted when users wish to locate an element from the diagram within elements collection
|
||||
void findElementRequired(const ElementsLocation &);
|
||||
/// Signal emitted when users wish to edit an element from the diagram
|
||||
void editElementRequired(const ElementsLocation &);
|
||||
};
|
||||
Q_DECLARE_METATYPE(Diagram *)
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "qetmessagebox.h"
|
||||
#include "qtextorientationspinboxwidget.h"
|
||||
#include <QGraphicsObject>
|
||||
|
||||
#include <ui/elementpropertieswidget.h>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
@ -88,6 +88,8 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(pare
|
||||
connect(&(scene -> border_and_titleblock), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
|
||||
connect(&(scene -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||
connect(&(scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(updateWindowTitle()));
|
||||
connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation)));
|
||||
connect(diagram, SIGNAL(findElementRequired(ElementsLocation)), this, SIGNAL(findElementRequired(ElementsLocation)));
|
||||
|
||||
connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection);
|
||||
connect(
|
||||
@ -881,42 +883,37 @@ void DiagramView::applyReadOnly() {
|
||||
Edite les proprietes des objets selectionnes
|
||||
*/
|
||||
void DiagramView::editSelectionProperties() {
|
||||
// recupere la selection
|
||||
// get selection
|
||||
DiagramContent selection = scene -> selectedContent();
|
||||
|
||||
// s'il n'y a rien de selectionne, cette methode ne fait rien
|
||||
// if selection contains nothing return
|
||||
int selected_items_count = selection.count(DiagramContent::All | DiagramContent::SelectedOnly);
|
||||
if (!selected_items_count) return;
|
||||
|
||||
// si la selection ne comprend qu'un seul objet, on l'edite via un dialogue approprie
|
||||
if (selected_items_count == 1) {
|
||||
// cas d'un conducteur selectionne
|
||||
QList<Conductor *> selected_conductors = selection.conductors(DiagramContent::AnyConductor | DiagramContent::SelectedOnly);
|
||||
if (selected_conductors.count() == 1) {
|
||||
editConductor(selected_conductors.at(0));
|
||||
return;
|
||||
}
|
||||
|
||||
// cas d'un element selectionne
|
||||
if (selection.elements.count() == 1) {
|
||||
editElement(selection.elements.toList().at(0));
|
||||
return;
|
||||
}
|
||||
|
||||
// cas d'un champ de texte selectionne : pour le moment, on traite comme une selection multiple
|
||||
// if selection contains one item and this item can be editable, edit this item with an appropriate dialog
|
||||
if (selected_items_count == 1 && selection.items(DiagramContent::Elements |
|
||||
DiagramContent::AnyConductor |
|
||||
DiagramContent::SelectedOnly).size()) {
|
||||
// edit conductor
|
||||
if (selection.conductors(DiagramContent::AnyConductor | DiagramContent::SelectedOnly).size())
|
||||
editConductor(selection.conductors().first());
|
||||
// edit element
|
||||
else if (selection.elements.size())
|
||||
selection.elements.toList().first() -> editProperty();
|
||||
}
|
||||
|
||||
// sinon on affiche un simple listing des elements selectionnes
|
||||
QET::MessageBox::information(
|
||||
this,
|
||||
tr("Propri\351t\351s de la s\351lection"),
|
||||
QString(
|
||||
tr(
|
||||
"La s\351lection contient %1.",
|
||||
"%1 is a sentence listing the selected objects"
|
||||
)
|
||||
).arg(selection.sentence(DiagramContent::All | DiagramContent::SelectedOnly))
|
||||
);
|
||||
else {
|
||||
QET::MessageBox::information(
|
||||
this,
|
||||
tr("Propri\351t\351s de la s\351lection"),
|
||||
QString(
|
||||
tr(
|
||||
"La s\351lection contient %1.",
|
||||
"%1 is a sentence listing the selected objects"
|
||||
)
|
||||
).arg(selection.sentence(DiagramContent::All | DiagramContent::SelectedOnly))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -933,75 +930,6 @@ void DiagramView::editSelectedConductorColor() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Affiche des informations sur un element
|
||||
@param element Element a afficher
|
||||
*/
|
||||
void DiagramView::editElement(Element *element) {
|
||||
if (!element) return;
|
||||
|
||||
CustomElement *custom_element = qobject_cast<CustomElement *>(element);
|
||||
GhostElement *ghost_element = qobject_cast<GhostElement *>(element);
|
||||
|
||||
// type de l'element
|
||||
QString description_string;
|
||||
if (ghost_element) {
|
||||
description_string += tr("\311l\351ment manquant");
|
||||
} else {
|
||||
description_string += tr("\311l\351ment");
|
||||
}
|
||||
description_string += "\n";
|
||||
|
||||
// nom, nombre de bornes, dimensions
|
||||
description_string += QString(tr("Nom\240: %1\n")).arg(element -> name());
|
||||
int folio_index = scene -> folioIndex();
|
||||
if (folio_index != -1) {
|
||||
description_string += QString(tr("Folio\240: %1\n")).arg(folio_index + 1);
|
||||
}
|
||||
description_string += QString(tr("Position\240: %1\n")).arg(scene -> convertPosition(element -> scenePos()).toString());
|
||||
description_string += QString(tr("Dimensions\240: %1\327%2\n")).arg(element -> size().width()).arg(element -> size().height());
|
||||
description_string += QString(tr("Bornes\240: %1\n")).arg(element -> terminals().count());
|
||||
description_string += QString(tr("Connexions internes\240: %1\n")).arg(element -> internalConnections() ? tr("Autoris\351es") : tr("Interdites"));
|
||||
description_string += QString(tr("Champs de texte\240: %1\n")).arg(element -> texts().count());
|
||||
|
||||
if (custom_element) {
|
||||
description_string += QString(tr("Emplacement\240: %1\n")).arg(custom_element -> location().toString());
|
||||
}
|
||||
|
||||
// titre et boutons du dialogue
|
||||
QString description_title = tr("Propri\351t\351s de l'\351l\351ment s\351lectionn\351");
|
||||
QPushButton *find_in_panel = new QPushButton(tr("Retrouver dans le panel"));
|
||||
QPushButton *edit_element = new QPushButton(tr("\311diter l'\351l\351ment"));
|
||||
edit_element->setIcon(QET::Icons::ElementEdit);
|
||||
|
||||
// dialogue en lui-meme
|
||||
QMessageBox edit_element_dialog(diagramEditor());
|
||||
#ifdef Q_WS_MAC
|
||||
edit_element_dialog.setWindowFlags(Qt::Sheet);
|
||||
#endif
|
||||
edit_element_dialog.setIcon(QMessageBox::Information);
|
||||
edit_element_dialog.setWindowTitle(description_title);
|
||||
edit_element_dialog.setText(description_title);
|
||||
edit_element_dialog.setInformativeText(description_string);
|
||||
edit_element_dialog.addButton(find_in_panel, QMessageBox::ApplyRole);
|
||||
edit_element_dialog.addButton(edit_element, QMessageBox::ApplyRole);
|
||||
edit_element_dialog.addButton(QMessageBox::Ok);
|
||||
edit_element_dialog.setDefaultButton(QMessageBox::Ok);
|
||||
edit_element_dialog.setEscapeButton(QMessageBox::Ok);
|
||||
edit_element_dialog.exec();
|
||||
|
||||
// Permet de trouver l'element dans la collection
|
||||
if (edit_element_dialog.clickedButton() == find_in_panel) {
|
||||
emit(findElementRequired(custom_element -> location()));
|
||||
}
|
||||
|
||||
// Trouve l'element dans la collection et l'edite
|
||||
if (edit_element_dialog.clickedButton() == edit_element) {
|
||||
emit(findElementRequired(custom_element -> location()));
|
||||
emit(editElementRequired(custom_element -> location()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Affiche un dialogue permettant d'editer le conducteur selectionne.
|
||||
Ne fait rien s'il y a 0 ou plusieurs conducteurs selectionnes.
|
||||
@ -1036,8 +964,8 @@ void DiagramView::editConductor(Conductor *edited_conductor) {
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&conductor_dialog);
|
||||
dialog_layout -> addWidget(cpw);
|
||||
QCheckBox *cb_apply_all = new QCheckBox(tr("Appliquer les propri\351t\351s \340 l'ensemble des conducteurs de ce potentiel"), &conductor_dialog);
|
||||
dialog_layout -> addWidget(cb_apply_all);
|
||||
dialog_layout -> addStretch();
|
||||
dialog_layout -> addWidget(cb_apply_all);
|
||||
QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
dbb -> setParent(&conductor_dialog);
|
||||
dialog_layout -> addWidget(dbb);
|
||||
@ -1427,8 +1355,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
if (QGraphicsItem *qgi = itemAt(e -> pos())) {
|
||||
if (Conductor *c = qgraphicsitem_cast<Conductor *>(qgi)) {
|
||||
editConductor(c);
|
||||
} else if (Element *element = qgraphicsitem_cast<Element *>(qgi)) {
|
||||
editElement(element);
|
||||
} else {
|
||||
QGraphicsView::mouseDoubleClickEvent(e);
|
||||
}
|
||||
|
@ -154,7 +154,6 @@ class DiagramView : public QGraphicsView {
|
||||
void updateWindowTitle();
|
||||
void editSelectionProperties();
|
||||
void editSelectedConductorColor();
|
||||
void editElement(Element *);
|
||||
void editConductor();
|
||||
void editConductor(Conductor *);
|
||||
void editConductorColor(Conductor *);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "elementtextitem.h"
|
||||
#include "diagramcommands.h"
|
||||
#include <QtDebug>
|
||||
#include <ui/elementpropertieswidget.h>
|
||||
|
||||
/**
|
||||
Constructeur pour un element sans scene ni parent
|
||||
@ -40,6 +41,16 @@ Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
||||
Element::~Element() {
|
||||
}
|
||||
|
||||
void Element::editProperty() {
|
||||
if (diagram())
|
||||
if(!diagram()->isReadOnly()){
|
||||
elementpropertieswidget epw (this, diagram()->views().first());
|
||||
connect(&epw, SIGNAL(editElementRequired(ElementsLocation)), diagram(), SIGNAL(editElementRequired(ElementsLocation)));
|
||||
connect(&epw, SIGNAL(findElementRequired(ElementsLocation)), diagram(), SIGNAL(findElementRequired(ElementsLocation)));
|
||||
epw.exec();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si l'element est mis en evidence
|
||||
*/
|
||||
|
@ -99,6 +99,7 @@ class Element : public QetGraphicsItem {
|
||||
bool internalConnections();
|
||||
void setInternalConnections(bool);
|
||||
virtual void rotateBy(const qreal &);
|
||||
virtual void editProperty();
|
||||
|
||||
// methods related to XML import/export
|
||||
static bool valideXml(QDomElement &);
|
||||
|
134
sources/ui/elementpropertieswidget.cpp
Normal file
134
sources/ui/elementpropertieswidget.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
#include "elementpropertieswidget.h"
|
||||
#include <qetgraphicsitem/ghostelement.h>
|
||||
#include <qeticons.h>
|
||||
#include <diagramposition.h>
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::elementpropertieswidget
|
||||
* default constructor
|
||||
* @param elmt
|
||||
* @param parent
|
||||
*/
|
||||
elementpropertieswidget::elementpropertieswidget(Element *elmt, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
element_ (elmt),
|
||||
diagram_ (elmt->diagram())
|
||||
{
|
||||
setWindowTitle(tr("Propri\351t\351s de l'\351l\351ment"));
|
||||
|
||||
tab_ = new QTabWidget(this);
|
||||
tab_ -> addTab(generalWidget(), tr("G\351n\351ral"));
|
||||
|
||||
dbb = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Reset,
|
||||
Qt::Horizontal, this);
|
||||
connect(dbb, SIGNAL(clicked(QAbstractButton*)), this, SLOT(standardButtonClicked(QAbstractButton*)));
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout -> addWidget(tab_);
|
||||
main_layout -> addWidget(dbb);
|
||||
setLayout(main_layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::generalWidget
|
||||
* build the widget for the tab général
|
||||
* @return
|
||||
*/
|
||||
QWidget* elementpropertieswidget::generalWidget() {
|
||||
CustomElement *custom_element = qobject_cast<CustomElement *>(element_);
|
||||
GhostElement *ghost_element = qobject_cast<GhostElement *>(element_);
|
||||
|
||||
// type de l'element
|
||||
QString description_string;
|
||||
if (ghost_element) {
|
||||
description_string += tr("\311l\351ment manquant");
|
||||
} else {
|
||||
description_string += tr("\311l\351ment");
|
||||
}
|
||||
description_string += "\n";
|
||||
|
||||
// some element characteristic
|
||||
description_string += QString(tr("Nom\240: %1\n")).arg(element_ -> name());
|
||||
int folio_index = diagram_ -> folioIndex();
|
||||
if (folio_index != -1) {
|
||||
description_string += QString(tr("Folio\240: %1\n")).arg(folio_index + 1);
|
||||
}
|
||||
description_string += QString(tr("Position\240: %1\n")).arg(diagram_ -> convertPosition(element_ -> scenePos()).toString());
|
||||
description_string += QString(tr("Dimensions\240: %1\327%2\n")).arg(element_ -> size().width()).arg(element_ -> size().height());
|
||||
description_string += QString(tr("Bornes\240: %1\n")).arg(element_ -> terminals().count());
|
||||
description_string += QString(tr("Champs de texte\240: %1\n")).arg(element_ -> texts().count());
|
||||
|
||||
if (custom_element) {
|
||||
description_string += QString(tr("Emplacement\240: %1\n")).arg(custom_element -> location().toString());
|
||||
}
|
||||
|
||||
// widget himself
|
||||
QWidget *general_widget = new QWidget (tab_);
|
||||
QVBoxLayout *vlayout_ = new QVBoxLayout (general_widget);
|
||||
general_widget -> setLayout(vlayout_);
|
||||
|
||||
//widget for the text
|
||||
vlayout_->addWidget(new QLabel (description_string, general_widget));
|
||||
|
||||
//widget for the pixmap
|
||||
QLabel *pix = new QLabel(general_widget);
|
||||
pix->setPixmap(element_->pixmap());
|
||||
vlayout_->addWidget(pix, 0, Qt::AlignHCenter);
|
||||
vlayout_ -> addStretch();
|
||||
|
||||
//button widget
|
||||
find_in_panel = new QPushButton(QET::Icons::ZoomDraw, tr("Retrouver dans le panel"), general_widget);
|
||||
connect(find_in_panel, SIGNAL(clicked()), this, SLOT(findInPanel()));
|
||||
edit_element = new QPushButton(QET::Icons::ElementEdit, tr("\311diter l'\351l\351ment"), general_widget);
|
||||
connect(edit_element, SIGNAL(clicked()), this, SLOT(editElement()));
|
||||
QHBoxLayout *hlayout_ = new QHBoxLayout;
|
||||
hlayout_->addWidget(find_in_panel);
|
||||
hlayout_->addWidget(edit_element);
|
||||
|
||||
vlayout_->addLayout(hlayout_);
|
||||
return general_widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::standardButtonClicked
|
||||
* apply action when click in the dialog standard button box
|
||||
* @param button
|
||||
* the cliked button
|
||||
*/
|
||||
void elementpropertieswidget::standardButtonClicked(QAbstractButton *button) {
|
||||
int answer = dbb -> buttonRole(button);
|
||||
|
||||
switch (answer) {
|
||||
case QDialogButtonBox::ResetRole:
|
||||
break;
|
||||
case QDialogButtonBox::ApplyRole:
|
||||
this->accept();
|
||||
case QDialogButtonBox::RejectRole:
|
||||
this->reject();
|
||||
default:
|
||||
this->reject();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::findInPanel
|
||||
* Slot
|
||||
*/
|
||||
void elementpropertieswidget::findInPanel() {
|
||||
if (CustomElement *custom_element = qobject_cast<CustomElement *>(element_)) {
|
||||
emit findElementRequired(custom_element->location());
|
||||
}
|
||||
reject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief elementpropertieswidget::editElement
|
||||
* Slot
|
||||
*/
|
||||
void elementpropertieswidget::editElement() {
|
||||
if (CustomElement *custom_element = qobject_cast<CustomElement *>(element_)) {
|
||||
emit findElementRequired(custom_element->location());
|
||||
emit editElementRequired(custom_element->location());
|
||||
}
|
||||
reject();
|
||||
}
|
37
sources/ui/elementpropertieswidget.h
Normal file
37
sources/ui/elementpropertieswidget.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef ELEMENTPROPERTIESWIDGET_H
|
||||
#define ELEMENTPROPERTIESWIDGET_H
|
||||
|
||||
#include <QtGui>
|
||||
#include <qetgraphicsitem/element.h>
|
||||
#include <diagram.h>
|
||||
|
||||
class elementpropertieswidget : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit elementpropertieswidget(Element *elmt, QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
QWidget* generalWidget();
|
||||
|
||||
signals:
|
||||
/// Signal emitted when users wish to locate an element from the diagram within elements collection
|
||||
void findElementRequired(const ElementsLocation &);
|
||||
/// Signal emitted when users wish to edit an element from the diagram
|
||||
void editElementRequired(const ElementsLocation &);
|
||||
|
||||
public slots:
|
||||
void standardButtonClicked (QAbstractButton *);
|
||||
void findInPanel ();
|
||||
void editElement ();
|
||||
|
||||
private:
|
||||
QDialogButtonBox *dbb;
|
||||
Element *element_;
|
||||
Diagram *diagram_;
|
||||
QTabWidget *tab_;
|
||||
QPushButton *find_in_panel, *edit_element;
|
||||
|
||||
};
|
||||
|
||||
#endif // ELEMENTPROPERTIESWIDGET_H
|
Loading…
x
Reference in New Issue
Block a user