mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-14 05:19:58 +01:00
Report element : minor improvement about text (text used to display the position of linked report is now tagged "label")
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3560 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -637,7 +637,8 @@ bool QETElementEditor::checkElement() {
|
||||
/// Check master, slave and simple element
|
||||
if(ce_scene -> elementType() == "master" ||
|
||||
ce_scene -> elementType() == "slave" ||
|
||||
ce_scene -> elementType() == "simple" ) {
|
||||
ce_scene -> elementType() == "simple" ||
|
||||
ce_scene -> elementType().contains("report")) {
|
||||
|
||||
bool wrng = true;
|
||||
foreach (CustomElementPart *cep, ce_scene->primitives()) {
|
||||
@@ -647,7 +648,7 @@ bool QETElementEditor::checkElement() {
|
||||
if (wrng) {
|
||||
errors << qMakePair(
|
||||
tr("Absence de champ texte 'label'", "warning title"),
|
||||
tr("Les \351l\351ments ma\356tres, esclaves et simple doivent poss\351der "
|
||||
tr("Les \351l\351ments ma\356tres, esclaves, simple et renvoie de folio doivent poss\351der "
|
||||
"un champ texte comportant le tagg 'label'", "warning description"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,21 @@ void ElementTextItem::adjustItemPosition(int new_block_count) {
|
||||
*/
|
||||
void ElementTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if ( (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) && !parent_element_ -> isFree())
|
||||
/*
|
||||
* Before revision 3559, report element haven't got text tagged label
|
||||
* so if parent is a report and haven't got text tagged label,
|
||||
* we know if this text is used has tagged label.
|
||||
*/
|
||||
bool report_text = false;
|
||||
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
|
||||
{
|
||||
//This is the first of list, so this text is used to display
|
||||
//pos of linked report.
|
||||
if (parent_element_ -> texts().first() == this)
|
||||
report_text = true;
|
||||
}
|
||||
|
||||
if ( (tagg_ == "label" || report_text) && !parent_element_ -> isFree())
|
||||
{
|
||||
//If parent is linked, show the linked element
|
||||
if ( parent_element_ -> linkType() & (Element::AllReport | Element::Slave) )
|
||||
@@ -289,10 +303,24 @@ void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
* @brief ElementTextItem::hoverEnterEvent
|
||||
* @param event
|
||||
*/
|
||||
void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
|
||||
|
||||
if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) {
|
||||
void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
/*
|
||||
* Before revision 3559, report element haven't got text tagged label
|
||||
* so if parent is a report and haven't got text tagged label,
|
||||
* we know if this text is used has tagged label.
|
||||
*/
|
||||
bool report_text = false;
|
||||
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
|
||||
{
|
||||
//This is the first of list, so this text is used to display
|
||||
//pos of linked report.
|
||||
if (parent_element_ -> texts().first() == this)
|
||||
report_text = true;
|
||||
}
|
||||
|
||||
if (tagg_ == "label" || report_text)
|
||||
{
|
||||
if (parent_element_ -> linkType() & (Element::AllReport | Element::Slave) && !parent_element_->isFree()) {
|
||||
|
||||
setDefaultTextColor(Qt::blue);
|
||||
@@ -312,10 +340,24 @@ void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
|
||||
* @brief ElementTextItem::hoverLeaveEvent
|
||||
* @param event
|
||||
*/
|
||||
void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
|
||||
if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) {
|
||||
void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
/*
|
||||
* Before revision 3559, report element haven't got text tagged label
|
||||
* so if parent is a report and haven't got text tagged label,
|
||||
* we know if this text is used has tagged label.
|
||||
*/
|
||||
bool report_text = false;
|
||||
if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label"))
|
||||
{
|
||||
//This is the first of list, so this text is used to display
|
||||
//pos of linked report.
|
||||
if (parent_element_ -> texts().first() == this)
|
||||
report_text = true;
|
||||
}
|
||||
|
||||
if (tagg_ == "label" || report_text)
|
||||
{
|
||||
if (defaultTextColor() != Qt::black)
|
||||
setDefaultTextColor(Qt::black);
|
||||
|
||||
|
||||
@@ -22,10 +22,21 @@
|
||||
#include "diagram.h"
|
||||
|
||||
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) :
|
||||
CustomElement(location, qgi, state)
|
||||
{
|
||||
if (!texts().isEmpty())
|
||||
texts().first()->setNoEditable();
|
||||
CustomElement(location, qgi, state),
|
||||
m_text_field (nullptr)
|
||||
{
|
||||
/*
|
||||
* Get text tagged label. This is work for report
|
||||
* create after the revision 3559.
|
||||
* for report create before, we take the first text field
|
||||
* because report haven't got a text field tagged label
|
||||
*/
|
||||
m_text_field = taggedText("label");
|
||||
if (!m_text_field && !texts().isEmpty())
|
||||
m_text_field = texts().first();
|
||||
if (m_text_field)
|
||||
m_text_field -> setNoEditable();
|
||||
|
||||
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
|
||||
link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport;
|
||||
}
|
||||
@@ -121,18 +132,21 @@ void ReportElement::setLabel(QString label) {
|
||||
* Update the displayed label.
|
||||
* ie the folio and position of the linked folio report
|
||||
*/
|
||||
void ReportElement::updateLabel() {
|
||||
if (texts().isEmpty()) return;
|
||||
ElementTextItem *text = texts().first();
|
||||
void ReportElement::updateLabel()
|
||||
{
|
||||
if (!m_text_field) return;
|
||||
|
||||
if (!connected_elements.isEmpty()){
|
||||
if (!connected_elements.isEmpty())
|
||||
{
|
||||
Element *elmt = connected_elements.at(0);
|
||||
QString label = label_;
|
||||
label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
|
||||
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
|
||||
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
|
||||
text->setPlainText(label);
|
||||
} else {
|
||||
text->setPlainText("/");
|
||||
m_text_field -> setPlainText(label);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_text_field -> setPlainText("/");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "customelement.h"
|
||||
|
||||
class ElementTextItem;
|
||||
|
||||
/**
|
||||
* @brief The ReportElement class
|
||||
*this class represent an element that can be linked to an other ReportElement
|
||||
@@ -37,8 +39,9 @@ class ReportElement : public CustomElement {
|
||||
virtual void unlinkElement(Element *elmt);
|
||||
|
||||
private:
|
||||
int inverse_report;
|
||||
QString label_;
|
||||
int inverse_report;
|
||||
QString label_;
|
||||
ElementTextItem *m_text_field;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user