mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
make user text for folio report none editable
Add signal mapper for radiobutton in the folio report dialog git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2679 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -37,6 +37,7 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram)
|
|||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::diagramTextsFont());
|
setFont(QETApp::diagramTextsFont());
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||||
|
setNoEditable(false);
|
||||||
#if QT_VERSION >= 0x040600
|
#if QT_VERSION >= 0x040600
|
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
#endif
|
#endif
|
||||||
@@ -59,6 +60,7 @@ DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Dia
|
|||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::diagramTextsFont());
|
setFont(QETApp::diagramTextsFont());
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||||
|
setNoEditable(false);
|
||||||
#if QT_VERSION >= 0x040600
|
#if QT_VERSION >= 0x040600
|
||||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
#endif
|
#endif
|
||||||
@@ -247,7 +249,7 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
|||||||
@param event un QGraphicsSceneMouseEvent decrivant le double-clic
|
@param event un QGraphicsSceneMouseEvent decrivant le double-clic
|
||||||
*/
|
*/
|
||||||
void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if (!(textInteractionFlags() & Qt::TextEditable)) {
|
if (!(textInteractionFlags() & Qt::TextEditable) && !no_editable) {
|
||||||
// rend le champ de texte editable
|
// rend le champ de texte editable
|
||||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
QPointF mapMovementToParent(const QPointF &) const;
|
QPointF mapMovementToParent(const QPointF &) const;
|
||||||
QPointF mapMovementFromParent(const QPointF &) const;
|
QPointF mapMovementFromParent(const QPointF &) const;
|
||||||
void setFontSize(int &s);
|
void setFontSize(int &s);
|
||||||
|
void setNoEditable(bool e = true) {no_editable = e;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
@@ -82,5 +83,6 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
QString previous_text_;
|
QString previous_text_;
|
||||||
/// angle of rotation of the text field
|
/// angle of rotation of the text field
|
||||||
qreal rotation_angle_;
|
qreal rotation_angle_;
|
||||||
|
bool no_editable;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,10 +16,13 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "reportelement.h"
|
#include "reportelement.h"
|
||||||
|
#include "elementtextitem.h"
|
||||||
|
|
||||||
ReportElement::ReportElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
ReportElement::ReportElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
||||||
CustomElement(location, qgi, s, state)
|
CustomElement(location, qgi, s, state)
|
||||||
{}
|
{
|
||||||
|
texts().at(0)->setNoEditable();
|
||||||
|
}
|
||||||
|
|
||||||
int ReportElement::linkType() const {
|
int ReportElement::linkType() const {
|
||||||
return REPORT;
|
return REPORT;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ elementpropertieswidget::elementpropertieswidget(Element *elmt, QWidget *parent)
|
|||||||
element_ (elmt),
|
element_ (elmt),
|
||||||
diagram_ (elmt->diagram())
|
diagram_ (elmt->diagram())
|
||||||
{
|
{
|
||||||
|
frp_ = 0;
|
||||||
buildInterface();
|
buildInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +130,7 @@ void elementpropertieswidget::standardButtonClicked(QAbstractButton *button) {
|
|||||||
case QDialogButtonBox::ResetRole:
|
case QDialogButtonBox::ResetRole:
|
||||||
break;
|
break;
|
||||||
case QDialogButtonBox::ApplyRole:
|
case QDialogButtonBox::ApplyRole:
|
||||||
|
if (frp_) frp_->Apply();
|
||||||
this->accept();
|
this->accept();
|
||||||
case QDialogButtonBox::RejectRole:
|
case QDialogButtonBox::RejectRole:
|
||||||
this->reject();
|
this->reject();
|
||||||
|
|||||||
@@ -3,19 +3,45 @@
|
|||||||
|
|
||||||
#include <diagramposition.h>
|
#include <diagramposition.h>
|
||||||
#include <elementprovider.h>
|
#include <elementprovider.h>
|
||||||
|
#include <qetgraphicsitem/elementtextitem.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FolioReportProperties::FolioReportProperties : Construcor
|
||||||
|
* @param elmt : The edited element
|
||||||
|
* @param parent : Parent widget
|
||||||
|
*/
|
||||||
FolioReportProperties::FolioReportProperties(Element *elmt, QWidget *parent) :
|
FolioReportProperties::FolioReportProperties(Element *elmt, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
element_(elmt),
|
element_(elmt),
|
||||||
|
element_to_link(0),
|
||||||
ui(new Ui::FolioReportProperties)
|
ui(new Ui::FolioReportProperties)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
sm_ = new QSignalMapper(this);
|
||||||
|
connect(sm_, SIGNAL(mapped(int)) , this, SLOT(linkToElement(int)));
|
||||||
|
|
||||||
|
BuildRadioList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FolioReportProperties::~FolioReportProperties : Destructor
|
||||||
|
*/
|
||||||
|
FolioReportProperties::~FolioReportProperties()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FolioReportProperties::BuildRadioList : build the radio list for each available folio report
|
||||||
|
*/
|
||||||
|
void FolioReportProperties::BuildRadioList() {
|
||||||
ElementProvider ep(element_->diagram()->project(), element_->diagram());
|
ElementProvider ep(element_->diagram()->project(), element_->diagram());
|
||||||
QList <Element *> elmt_list = ep.FreeElement(REPORT);
|
QList <Element *> elmt_list = ep.FreeElement(REPORT);
|
||||||
|
|
||||||
foreach (Element *elmt, elmt_list) {
|
foreach (Element *elmt, elmt_list) {
|
||||||
if (elmt != element_) {
|
if (elmt != element_) {
|
||||||
|
//label for the button
|
||||||
QString button_text;
|
QString button_text;
|
||||||
QString title = elmt->diagram()->title();
|
QString title = elmt->diagram()->title();
|
||||||
if (title.isEmpty()) title = tr("Sans titre");
|
if (title.isEmpty()) title = tr("Sans titre");
|
||||||
@@ -23,14 +49,22 @@ FolioReportProperties::FolioReportProperties(Element *elmt, QWidget *parent) :
|
|||||||
.arg(title)
|
.arg(title)
|
||||||
.arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
|
.arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
|
||||||
|
|
||||||
|
//button himself
|
||||||
QRadioButton *rb = new QRadioButton(button_text , this);
|
QRadioButton *rb = new QRadioButton(button_text , this);
|
||||||
ui->available_report_layout->addWidget(rb);
|
ui->available_report_layout->addWidget(rb);
|
||||||
|
element_list << elmt;
|
||||||
|
//map the radio button signal
|
||||||
|
connect(rb, SIGNAL(clicked()), sm_, SLOT(map()));
|
||||||
|
sm_ -> setMapping(rb, element_list.size()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->available_report_layout->addStretch();
|
ui->available_report_layout->addStretch();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolioReportProperties::~FolioReportProperties()
|
/**
|
||||||
{
|
* @brief FolioReportProperties::Apply
|
||||||
delete ui;
|
* Apply the new properties for this folio report
|
||||||
|
*/
|
||||||
|
void FolioReportProperties::Apply() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,19 @@ class FolioReportProperties : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit FolioReportProperties(Element *elmt, QWidget *parent = 0);
|
explicit FolioReportProperties(Element *elmt, QWidget *parent = 0);
|
||||||
~FolioReportProperties();
|
~FolioReportProperties();
|
||||||
|
void BuildRadioList();
|
||||||
|
void Apply();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void linkToElement(const int i) {element_to_link = element_list.at(i);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Element *element_;
|
Element *element_, *element_to_link;
|
||||||
|
QList <Element *> element_list;
|
||||||
Ui::FolioReportProperties *ui;
|
Ui::FolioReportProperties *ui;
|
||||||
|
QSignalMapper *sm_;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FOLIOREPORTPROPERTIES_H
|
#endif // FOLIOREPORTPROPERTIES_H
|
||||||
|
|||||||
Reference in New Issue
Block a user