[qet] [2679] make user text for folio report none editable

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2679
Author:   blacksun
Date:     2013-12-29 19:09:25 +0100 (Sun, 29 Dec 2013)
Log Message:
-----------
make user text for folio report none editable
Add signal mapper for radiobutton in the folio report dialog

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/diagramtextitem.cpp
    trunk/sources/qetgraphicsitem/diagramtextitem.h
    trunk/sources/qetgraphicsitem/reportelement.cpp
    trunk/sources/ui/elementpropertieswidget.cpp
    trunk/sources/ui/folioreportproperties.cpp
    trunk/sources/ui/folioreportproperties.h

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2013-12-29 17:51:01 UTC (rev 2678)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.cpp	2013-12-29 18:09:25 UTC (rev 2679)
@@ -37,6 +37,7 @@
 	setDefaultTextColor(Qt::black);
 	setFont(QETApp::diagramTextsFont());
 	setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
+	setNoEditable(false);
 #if QT_VERSION >= 0x040600
 	setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
 #endif
@@ -59,6 +60,7 @@
 	setDefaultTextColor(Qt::black);
 	setFont(QETApp::diagramTextsFont());
 	setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
+	setNoEditable(false);
 #if QT_VERSION >= 0x040600
 	setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
 #endif
@@ -247,7 +249,7 @@
 	@param event un QGraphicsSceneMouseEvent decrivant le double-clic
 */
 void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
-	if (!(textInteractionFlags() & Qt::TextEditable)) {
+	if (!(textInteractionFlags() & Qt::TextEditable) && !no_editable) {
 		// rend le champ de texte editable
 		setTextInteractionFlags(Qt::TextEditorInteraction);
 		

Modified: trunk/sources/qetgraphicsitem/diagramtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.h	2013-12-29 17:51:01 UTC (rev 2678)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.h	2013-12-29 18:09:25 UTC (rev 2679)
@@ -59,6 +59,7 @@
 	QPointF mapMovementToParent(const QPointF &) const;
 	QPointF mapMovementFromParent(const QPointF &) const;
 	void setFontSize(int &s);
+	void setNoEditable(bool e = true) {no_editable = e;}
 	
 	protected:
 	virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
@@ -82,5 +83,6 @@
 	QString previous_text_;
 	/// angle of rotation of the text field
 	qreal rotation_angle_;
+	bool no_editable;
 };
 #endif

Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp	2013-12-29 17:51:01 UTC (rev 2678)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp	2013-12-29 18:09:25 UTC (rev 2679)
@@ -16,10 +16,13 @@
 	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "reportelement.h"
+#include "elementtextitem.h"
 
 ReportElement::ReportElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
 	CustomElement(location, qgi, s, state)
-{}
+{
+	texts().at(0)->setNoEditable();
+}
 
 int ReportElement::linkType() const {
 	return REPORT;

Modified: trunk/sources/ui/elementpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/elementpropertieswidget.cpp	2013-12-29 17:51:01 UTC (rev 2678)
+++ trunk/sources/ui/elementpropertieswidget.cpp	2013-12-29 18:09:25 UTC (rev 2679)
@@ -14,6 +14,7 @@
 	element_ (elmt),
 	diagram_ (elmt->diagram())
 {
+	frp_ = 0;
 	buildInterface();
 }
 
@@ -129,6 +130,7 @@
 		case QDialogButtonBox::ResetRole:
 			break;
 		case QDialogButtonBox::ApplyRole:
+			if (frp_) frp_->Apply();
 			this->accept();
 		case QDialogButtonBox::RejectRole:
 			this->reject();

Modified: trunk/sources/ui/folioreportproperties.cpp
===================================================================
--- trunk/sources/ui/folioreportproperties.cpp	2013-12-29 17:51:01 UTC (rev 2678)
+++ trunk/sources/ui/folioreportproperties.cpp	2013-12-29 18:09:25 UTC (rev 2679)
@@ -3,19 +3,45 @@
 
 #include <diagramposition.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) :
 	QWidget(parent),
 	element_(elmt),
+	element_to_link(0),
 	ui(new Ui::FolioReportProperties)
 {
 	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());
 	QList <Element *> elmt_list = ep.FreeElement(REPORT);
 
 	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");
@@ -23,14 +49,22 @@
 																		  .arg(title)
 																		  .arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
 
+			//button himself
 			QRadioButton *rb = new QRadioButton(button_text , this);
 			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();
 }
 
-FolioReportProperties::~FolioReportProperties()
-{
-	delete ui;
+/**
+ * @brief FolioReportProperties::Apply
+ * Apply the new properties for this folio report
+ */
+void FolioReportProperties::Apply() {
+
 }

Modified: trunk/sources/ui/folioreportproperties.h
===================================================================
--- trunk/sources/ui/folioreportproperties.h	2013-12-29 17:51:01 UTC (rev 2678)
+++ trunk/sources/ui/folioreportproperties.h	2013-12-29 18:09:25 UTC (rev 2679)
@@ -15,10 +15,19 @@
 	public:
 	explicit FolioReportProperties(Element *elmt, QWidget *parent = 0);
 	~FolioReportProperties();
+	void BuildRadioList();
+	void Apply();
 
+	private slots:
+	void linkToElement(const int i) {element_to_link = element_list.at(i);}
+
 	private:
-	Element *element_;
+	Element *element_, *element_to_link;
+	QList <Element *> element_list;
 	Ui::FolioReportProperties *ui;
+	QSignalMapper *sm_;
+
+
 };
 
 #endif // FOLIOREPORTPROPERTIES_H


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/