mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-10-01 11:40:02 +03:00
WIP
This commit is contained in:
@@ -36,7 +36,7 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
delta = genNextValue(delta);
|
||||
|
||||
qreal vStep = (barsRect.height()-painter->fontMetrics().height()) / valuesCount() / seriesCount();
|
||||
qreal hStep = (barsRect.width()-painter->fontMetrics().width(QString::number(maxValue()))) / delta;
|
||||
qreal hStep = (barsRect.width()-painter->fontMetrics().boundingRect(QString::number(maxValue())).width()) / delta;
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){
|
||||
int curSeries = 0;
|
||||
|
@@ -8,13 +8,12 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle
|
||||
|
||||
QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2);
|
||||
qreal percent = angle/3.6;
|
||||
#ifdef HAVE_QT4
|
||||
#if QT_VERSION < 0x050000
|
||||
qreal radAngle = (angle/2+startAngle)*(M_PI/180);
|
||||
#endif
|
||||
#ifdef HAVE_QT5
|
||||
#else
|
||||
qreal radAngle = qDegreesToRadians(angle/2+startAngle);
|
||||
#endif
|
||||
qreal radius = painter->fontMetrics().width("99,9%");
|
||||
qreal radius = painter->fontMetrics().boundingRect("99,9%").width();
|
||||
qreal border = chartRect.height()*0.02;
|
||||
qreal length = (chartRect.height())/2-(radius/2+border);
|
||||
qreal x,y;
|
||||
@@ -155,14 +154,14 @@ QSizeF PieChart::calcChartLegendSize(const QFont &font)
|
||||
SeriesItem* si = m_chartItem->series().at(0);
|
||||
foreach(QString label, si->data()->labels()){
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.width(label))
|
||||
maxWidth = fm.width(label)+10;
|
||||
if (maxWidth<fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width()+10;
|
||||
}
|
||||
} else {
|
||||
foreach(QString label, m_designLabels){
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.width(label))
|
||||
maxWidth = fm.width(label)+10;
|
||||
if (maxWidth<fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width()+10;
|
||||
}
|
||||
}
|
||||
cw += fm.height();
|
||||
|
@@ -53,7 +53,7 @@ void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, cons
|
||||
|
||||
void ItemsBordersEditorWidget::noBordesClicked()
|
||||
{
|
||||
updateValues(0);
|
||||
updateValues({});
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::allBordesClicked()
|
||||
@@ -148,7 +148,7 @@ void ItemsBordersEditorWidgetForDesigner::buttonClicked(bool)
|
||||
|
||||
void ItemsBordersEditorWidgetForDesigner::noBordesClicked()
|
||||
{
|
||||
m_reportEditor->setBorders(0);
|
||||
m_reportEditor->setBorders({});
|
||||
ItemsBordersEditorWidget::noBordesClicked();
|
||||
}
|
||||
|
||||
|
@@ -108,7 +108,7 @@ void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align)
|
||||
|
||||
Qt::Alignment TextAlignmentEditorWidget::createAlignment()
|
||||
{
|
||||
Qt::Alignment align = 0 ;
|
||||
Qt::Alignment align = Qt::Alignment();
|
||||
if (m_textAliginLeft->isChecked()) align |= Qt::AlignLeft;
|
||||
if (m_textAliginHCenter->isChecked()) align |= Qt::AlignHCenter;
|
||||
if (m_textAliginRight->isChecked()) align |= Qt::AlignRight;
|
||||
|
@@ -30,9 +30,9 @@ namespace LimeReport{
|
||||
|
||||
QColor generateColor()
|
||||
{
|
||||
int red = (qrand()%(256 - 1)) + 1;
|
||||
int green = (qrand()%(256 - 1)) + 1;
|
||||
int blue = (qrand()%(256 - 1)) + 1;;
|
||||
int red = (rand()%(256 - 1)) + 1;
|
||||
int green = (rand()%(256 - 1)) + 1;
|
||||
int blue = (rand()%(256 - 1)) + 1;;
|
||||
return QColor(red,green,blue);
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ void ChartItem::paintChartTitle(QPainter *painter, QRectF titleRect)
|
||||
painter->save();
|
||||
QFont tmpFont = painter->font();
|
||||
QFontMetrics fm(tmpFont);
|
||||
while ((fm.height()>titleRect.height() || fm.width(m_title)>titleRect.width())
|
||||
while ((fm.height()>titleRect.height() || fm.boundingRect(m_title).width()>titleRect.width())
|
||||
&& tmpFont.pixelSize()>1) {
|
||||
tmpFont.setPixelSize(tmpFont.pixelSize()-1);
|
||||
fm = QFontMetrics(tmpFont);
|
||||
@@ -570,14 +570,14 @@ QSizeF AbstractSeriesChart::calcChartLegendSize(const QFont &font)
|
||||
if (!m_chartItem->series().isEmpty()){
|
||||
foreach(SeriesItem* series, m_chartItem->series()){
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.width(series->name()))
|
||||
maxWidth = fm.width(series->name())+10;
|
||||
if (maxWidth<fm.boundingRect(series->name()).width())
|
||||
maxWidth = fm.boundingRect(series->name()).width()+10;
|
||||
}
|
||||
} else {
|
||||
foreach(QString label, m_designLabels){
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.width(label))
|
||||
maxWidth = fm.width(label)+10;
|
||||
if (maxWidth<fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width()+10;
|
||||
}
|
||||
}
|
||||
cw += fm.height();
|
||||
@@ -591,7 +591,7 @@ bool AbstractSeriesChart::verticalLabels(QPainter* painter, QRectF labelsRect)
|
||||
qreal hStep = (labelsRect.width() / valuesCount());
|
||||
QFontMetrics fm = painter->fontMetrics();
|
||||
foreach(QString label, m_chartItem->labels()){
|
||||
if (fm.width(label) > hStep){
|
||||
if (fm.boundingRect(label).width() > hStep){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -656,7 +656,7 @@ void AbstractSeriesChart::paintHorizontalGrid(QPainter *painter, QRectF gridRect
|
||||
delta = genNextValue(delta);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing,false);
|
||||
qreal hStep = (gridRect.width() - painter->fontMetrics().width(QString::number(maxValue()))) / 4;
|
||||
qreal hStep = (gridRect.width() - painter->fontMetrics().boundingRect(QString::number(maxValue())).width()) / 4;
|
||||
|
||||
painter->setFont(adaptValuesFont(hStep-4, painter->font()));
|
||||
|
||||
@@ -708,7 +708,7 @@ qreal AbstractSeriesChart::valuesHMargin(QPainter *painter)
|
||||
{
|
||||
int delta = int(maxValue()-minValue());
|
||||
delta = genNextValue(delta);
|
||||
return painter->fontMetrics().width(QString::number(delta))+4;
|
||||
return painter->fontMetrics().boundingRect(QString::number(delta)).width()+4;
|
||||
}
|
||||
|
||||
qreal AbstractSeriesChart::valuesVMargin(QPainter *painter)
|
||||
@@ -722,17 +722,21 @@ QFont AbstractSeriesChart::adaptLabelsFont(QRectF rect, QFont font)
|
||||
QFontMetrics fm(font);
|
||||
|
||||
foreach(QString label, m_chartItem->labels()){
|
||||
#if QT_VERSION < 0x060000
|
||||
foreach (QString currentWord, label.split(QRegExp("\\W+"))){
|
||||
if (fm.width(maxWord) < fm.width(currentWord)) maxWord = currentWord;
|
||||
#else
|
||||
foreach (QString currentWord, label.split(QRegularExpression("\\W+"))){
|
||||
#endif
|
||||
if (fm.boundingRect(maxWord).width() < fm.boundingRect(currentWord).width()) maxWord = currentWord;
|
||||
}
|
||||
}
|
||||
|
||||
qreal curWidth = fm.width(maxWord);
|
||||
qreal curWidth = fm.boundingRect(maxWord).width();
|
||||
QFont tmpFont = font;
|
||||
while (curWidth>rect.width() && tmpFont.pixelSize() > 1){
|
||||
tmpFont.setPixelSize(tmpFont.pixelSize() - 1);
|
||||
QFontMetricsF tmpFM(tmpFont);
|
||||
curWidth = tmpFM.width(maxWord);
|
||||
curWidth = tmpFM.boundingRect(maxWord).width();
|
||||
}
|
||||
return tmpFont;
|
||||
}
|
||||
@@ -742,11 +746,11 @@ QFont AbstractSeriesChart::adaptValuesFont(qreal width, QFont font)
|
||||
QString strValue = QString::number(maxValue());
|
||||
QFont tmpFont = font;
|
||||
QScopedPointer<QFontMetricsF> fm(new QFontMetricsF(tmpFont));
|
||||
qreal curWidth = fm->width(strValue);
|
||||
qreal curWidth = fm->boundingRect(strValue).width();
|
||||
while (curWidth > width && tmpFont.pixelSize() > 1){
|
||||
tmpFont.setPixelSize(tmpFont.pixelSize() - 1);
|
||||
fm.reset(new QFontMetricsF(tmpFont));
|
||||
curWidth = fm->width(strValue);
|
||||
curWidth = fm->boundingRect(strValue).width();
|
||||
}
|
||||
return tmpFont;
|
||||
}
|
||||
@@ -803,8 +807,8 @@ QRectF AbstractBarChart::verticalLabelsRect(QPainter *painter, QRectF labelsRect
|
||||
qreal maxWidth = 0;
|
||||
|
||||
foreach (QString label, m_chartItem->labels()) {
|
||||
if (painter->fontMetrics().width(label)>maxWidth)
|
||||
maxWidth = painter->fontMetrics().width(label);
|
||||
if (painter->fontMetrics().boundingRect(label).width()>maxWidth)
|
||||
maxWidth = painter->fontMetrics().boundingRect(label).width();
|
||||
}
|
||||
|
||||
if (maxWidth + hPadding(m_chartItem->rect()) * 2 < labelsRect.width())
|
||||
@@ -818,8 +822,8 @@ QRectF AbstractBarChart::horizontalLabelsRect(QPainter *painter, QRectF labelsRe
|
||||
qreal maxWidth = 0;
|
||||
|
||||
foreach (QString label, m_chartItem->labels()) {
|
||||
if (painter->fontMetrics().width(label)>maxWidth)
|
||||
maxWidth = painter->fontMetrics().width(label);
|
||||
if (painter->fontMetrics().boundingRect(label).width()>maxWidth)
|
||||
maxWidth = painter->fontMetrics().boundingRect(label).width();
|
||||
}
|
||||
|
||||
if ((maxWidth + vPadding(m_chartItem->rect()) < labelsRect.height()) || !verticalLabels(painter, labelsRect))
|
||||
|
@@ -10,7 +10,7 @@ ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDe
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QHBoxLayout* colorLayout = new QHBoxLayout();
|
||||
colorLayout->setMargin(0);
|
||||
colorLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_colorButton = new QToolButton();
|
||||
m_colorButton->setText("...");
|
||||
m_colorButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
@@ -118,11 +118,10 @@ void ChartItemEditor::init()
|
||||
ui->seriesTypeComboBox->addItem(enumerator.key(i));
|
||||
}
|
||||
|
||||
#ifdef HAVE_QT5
|
||||
ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField());
|
||||
#endif
|
||||
#ifdef HAVE_QT4
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->labelsFieldComboBox->setCurrentIndex(ui->labelsFieldComboBox->findText( m_charItem->labelsField()));
|
||||
#else
|
||||
ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField());
|
||||
#endif
|
||||
if (!m_charItem->series().isEmpty()){
|
||||
enableSeriesEditor();
|
||||
@@ -150,11 +149,10 @@ void ChartItemEditor::disableSeriesEditor()
|
||||
ui->valuesFieldComboBox->setDisabled(true);
|
||||
m_colorButton->setDisabled(true);
|
||||
m_colorIndicator->setDisabled(true);
|
||||
#ifdef HAVE_QT5
|
||||
ui->valuesFieldComboBox->setCurrentText("");
|
||||
#endif
|
||||
#ifdef HAVE_QT4
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->valuesFieldComboBox->setEditText("");
|
||||
#else
|
||||
ui->valuesFieldComboBox->setCurrentText("");
|
||||
#endif
|
||||
ui->seriesTypeComboBox->setDisabled(true);
|
||||
}
|
||||
@@ -208,11 +206,10 @@ void ChartItemEditor::slotAddSeries()
|
||||
ui->tableWidget->setRowCount(m_charItem->series().count());
|
||||
ui->tableWidget->setItem(m_charItem->series().count()-1, 0, new QTableWidgetItem(series->name()));
|
||||
ui->tableWidget->selectRow(m_charItem->series().count()-1);
|
||||
#ifdef HAVE_QT5
|
||||
ui->valuesFieldComboBox->setCurrentText("");
|
||||
#endif
|
||||
#ifdef HAVE_QT4
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->valuesFieldComboBox->setEditText("");
|
||||
#else
|
||||
ui->valuesFieldComboBox->setCurrentText("");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -235,20 +232,18 @@ void ChartItemEditor::on_tableWidget_itemSelectionChanged()
|
||||
if (ui->tableWidget->selectionModel()->hasSelection()){
|
||||
LimeReport::SeriesItem* series = m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row());
|
||||
ui->seriesNameLineEdit->setText(series->name());
|
||||
#ifdef HAVE_QT5
|
||||
ui->valuesFieldComboBox->setCurrentText(series->valuesColumn());
|
||||
#endif
|
||||
#ifdef HAVE_QT4
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->valuesFieldComboBox->setCurrentIndex(ui->valuesFieldComboBox->findText(series->valuesColumn()));
|
||||
#else
|
||||
ui->valuesFieldComboBox->setCurrentText(series->valuesColumn());
|
||||
#endif
|
||||
m_colorIndicator->setColor(series->color());
|
||||
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
|
||||
#ifdef HAVE_QT5
|
||||
ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType()));
|
||||
#endif
|
||||
#ifdef HAVE_QT4
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->seriesTypeComboBox->setCurrentIndex(ui->seriesTypeComboBox->findText(enumerator.valueToKey(series->preferredType())));
|
||||
#else
|
||||
ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType()));
|
||||
#endif
|
||||
enableSeriesEditor();
|
||||
}
|
||||
|
@@ -140,7 +140,7 @@ void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign)
|
||||
|
||||
void HorizontalLayout::sortChildren()
|
||||
{
|
||||
qSort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
}
|
||||
|
||||
void HorizontalLayout::updateLayoutSize()
|
||||
@@ -177,7 +177,7 @@ void HorizontalLayout::relocateChildren()
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
}
|
||||
qSort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
qreal curX = spaceBorder;
|
||||
setIsRelocating(true);
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
|
@@ -63,7 +63,7 @@ void VerticalLayout::relocateChildren()
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
}
|
||||
qSort(layoutsChildren().begin(),layoutsChildren().end(), verticalLessThen);
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(), verticalLessThen);
|
||||
qreal curY = spaceBorder;
|
||||
setIsRelocating(true);
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
@@ -140,7 +140,7 @@ BaseDesignIntf* VerticalLayout::cloneBottomPart(int height, QObject* owner, QGra
|
||||
|
||||
void VerticalLayout::sortChildren()
|
||||
{
|
||||
qSort(layoutsChildren().begin(),layoutsChildren().end(),verticalLessThen);
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),verticalLessThen);
|
||||
}
|
||||
|
||||
void VerticalLayout::divideSpace()
|
||||
|
Reference in New Issue
Block a user