2011-12-25 17:45:39 +00:00
|
|
|
|
#include "titleblockcell.h"
|
|
|
|
|
#include "titleblocktemplate.h"
|
|
|
|
|
/**
|
|
|
|
|
Constructor
|
|
|
|
|
*/
|
|
|
|
|
TitleBlockCell::TitleBlockCell() {
|
|
|
|
|
cell_type = TitleBlockCell::EmptyCell;
|
|
|
|
|
num_row = num_col = -1;
|
|
|
|
|
row_span = col_span = 0;
|
|
|
|
|
spanner_cell = 0;
|
|
|
|
|
display_label = true;
|
|
|
|
|
alignment = Qt::AlignCenter | Qt::AlignVCenter;
|
|
|
|
|
font_size = 9;
|
|
|
|
|
hadjust = false;
|
|
|
|
|
logo_reference = QString("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Destructor
|
|
|
|
|
*/
|
|
|
|
|
TitleBlockCell::~TitleBlockCell() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return A string representing the titleblock cell
|
|
|
|
|
*/
|
|
|
|
|
QString TitleBlockCell::toString() const {
|
|
|
|
|
if (cell_type == TitleBlockCell::EmptyCell) return("TitleBlockCell{null}");
|
|
|
|
|
QString span_desc = (row_span > 0 || col_span > 0) ? QString("+%1,%2").arg(row_span).arg(col_span) : QET::pointerString(spanner_cell);
|
|
|
|
|
QString base_desc = QString("TitleBlockCell{ [%1, %2] %3 }").arg(num_row).arg(num_col).arg(span_desc);
|
|
|
|
|
return(base_desc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return the type of this cell
|
|
|
|
|
*/
|
|
|
|
|
TitleBlockCell::TemplateCellType TitleBlockCell::type() const {
|
|
|
|
|
return(cell_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return the horizontal alignment of this cell
|
|
|
|
|
*/
|
|
|
|
|
int TitleBlockCell::horizontalAlign() const {
|
|
|
|
|
return(alignment & Qt::AlignHorizontal_Mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return the vertical alignment of this cell
|
|
|
|
|
*/
|
|
|
|
|
int TitleBlockCell::verticalAlign() const {
|
|
|
|
|
return(alignment & Qt::AlignVertical_Mask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Set the new value \a attr_value to the attribute named \a attribute.
|
|
|
|
|
@param attribute Name of the cell attribute which value is to be changed
|
|
|
|
|
@param attr_value New value of the changed attribute
|
|
|
|
|
*/
|
|
|
|
|
void TitleBlockCell::setAttribute(const QString &attribute, const QVariant &attr_value) {
|
|
|
|
|
if (attribute == "type") {
|
|
|
|
|
int new_type = attr_value.toInt();
|
|
|
|
|
if (new_type <= TitleBlockCell::LogoCell) {
|
|
|
|
|
cell_type = static_cast<TitleBlockCell::TemplateCellType>(new_type);
|
|
|
|
|
}
|
|
|
|
|
} else if (attribute == "name") {
|
|
|
|
|
value_name = attr_value.toString();
|
|
|
|
|
} else if (attribute == "logo") {
|
|
|
|
|
logo_reference = attr_value.toString();
|
|
|
|
|
} else if (attribute == "label") {
|
|
|
|
|
label = qvariant_cast<NamesList>(attr_value);
|
|
|
|
|
} else if (attribute == "displaylabel") {
|
|
|
|
|
display_label = attr_value.toBool();
|
|
|
|
|
} else if (attribute == "value") {
|
|
|
|
|
value = qvariant_cast<NamesList>(attr_value);
|
|
|
|
|
} else if (attribute == "alignment") {
|
|
|
|
|
alignment = attr_value.toInt();
|
|
|
|
|
} else if (attribute == "fontsize") {
|
|
|
|
|
font_size = attr_value.toInt();
|
|
|
|
|
} else if (attribute == "horizontal_adjust") {
|
|
|
|
|
hadjust = attr_value.toBool();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@param attribute Name of the cell attribute which value is wanted
|
|
|
|
|
@return the value of the required attribute
|
|
|
|
|
*/
|
|
|
|
|
QVariant TitleBlockCell::attribute(const QString &attribute) {
|
|
|
|
|
if (attribute == "type") {
|
|
|
|
|
return(type());
|
|
|
|
|
} else if (attribute == "name") {
|
|
|
|
|
return(value_name);
|
|
|
|
|
} else if (attribute == "logo") {
|
|
|
|
|
return(logo_reference);
|
|
|
|
|
} else if (attribute == "label") {
|
|
|
|
|
return(qVariantFromValue(label));
|
|
|
|
|
} else if (attribute == "displaylabel") {
|
|
|
|
|
return(display_label);
|
|
|
|
|
} else if (attribute == "value") {
|
|
|
|
|
return(qVariantFromValue(value));
|
|
|
|
|
} else if (attribute == "alignment") {
|
|
|
|
|
return(alignment);
|
|
|
|
|
} else if (attribute == "fontsize") {
|
|
|
|
|
return(TitleBlockTemplate::fontForCell(*this).pointSizeF());
|
|
|
|
|
} else if (attribute == "horizontal_adjust") {
|
|
|
|
|
return(hadjust);
|
|
|
|
|
}
|
|
|
|
|
return(QVariant());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@param attribute Name of the cell attribute which we want the human, translated name
|
|
|
|
|
@return the human, translated name for this attribute.
|
|
|
|
|
*/
|
|
|
|
|
QString TitleBlockCell::attributeName(const QString &attribute) {
|
|
|
|
|
if (attribute == "type") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("type", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "name") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("nom", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "logo") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("logo", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "label") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("label", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "displaylabel") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("affichage du label", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "value") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("valeur affich<63>e", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "alignment") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("alignement du texte", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "fontsize") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("taille du texte", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
} else if (attribute == "horizontal_adjust") {
|
2011-12-25 18:22:39 +00:00
|
|
|
|
return(QObject::tr("ajustement horizontal", "title block cell property human name"));
|
2011-12-25 17:45:39 +00:00
|
|
|
|
}
|
|
|
|
|
return(QString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return true if this cell spans over other cells, false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
bool TitleBlockCell::spans() const {
|
|
|
|
|
return(row_span || col_span);
|
|
|
|
|
}
|