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);
|
||||
setFont(QETApp::diagramTextsFont());
|
||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||
setNoEditable(false);
|
||||
#if QT_VERSION >= 0x040600
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
#endif
|
||||
@@ -59,6 +60,7 @@ DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Dia
|
||||
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 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
||||
@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);
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ class DiagramTextItem : public QGraphicsTextItem {
|
||||
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 @@ class DiagramTextItem : public QGraphicsTextItem {
|
||||
QString previous_text_;
|
||||
/// angle of rotation of the text field
|
||||
qreal rotation_angle_;
|
||||
bool no_editable;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14,6 +14,7 @@ elementpropertieswidget::elementpropertieswidget(Element *elmt, QWidget *parent)
|
||||
element_ (elmt),
|
||||
diagram_ (elmt->diagram())
|
||||
{
|
||||
frp_ = 0;
|
||||
buildInterface();
|
||||
}
|
||||
|
||||
@@ -129,6 +130,7 @@ void elementpropertieswidget::standardButtonClicked(QAbstractButton *button) {
|
||||
case QDialogButtonBox::ResetRole:
|
||||
break;
|
||||
case QDialogButtonBox::ApplyRole:
|
||||
if (frp_) frp_->Apply();
|
||||
this->accept();
|
||||
case QDialogButtonBox::RejectRole:
|
||||
this->reject();
|
||||
|
||||
@@ -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 @@ FolioReportProperties::FolioReportProperties(Element *elmt, QWidget *parent) :
|
||||
.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() {
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,19 @@ class FolioReportProperties : public QWidget
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user