Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/reports/kreportchartview.cpp
Show First 20 Lines • Show All 309 Lines • ▼ Show 20 Line(s) | 300 | if (rowTypeList[i] != eBudgetDiff) { | |||
---|---|---|---|---|---|
310 | //set the legend text | 310 | //set the legend text | ||
311 | legend->setText(rowNum, legendText); | 311 | legend->setText(rowNum, legendText); | ||
312 | 312 | | |||
313 | //clear to speed up drawPivotRowSet | 313 | //clear to speed up drawPivotRowSet | ||
314 | if (!config.isChartDataLabels()) | 314 | if (!config.isChartDataLabels()) | ||
315 | legendText.clear(); | 315 | legendText.clear(); | ||
316 | 316 | | |||
317 | //set the cell value and tooltip | 317 | //set the cell value and tooltip | ||
318 | rowNum = drawPivotRowSet(it_row.key().id(), rowNum, it_row.value(), rowTypeList[i], legendText, 1, numColumns() - 1); | 318 | rowNum = drawPivotRowSet(it_row.key().id(), rowNum, it_row.value(), rowTypeList[i], legendText, 0, numColumns()); | ||
319 | } | 319 | } | ||
320 | } | 320 | } | ||
321 | } | 321 | } | ||
322 | ++it_row; | 322 | ++it_row; | ||
323 | } | 323 | } | ||
324 | ++it_innergroup; | 324 | ++it_innergroup; | ||
325 | } | 325 | } | ||
326 | ++it_outergroup; | 326 | ++it_outergroup; | ||
Show All 27 Lines | 344 | if (rowTypeList[i] != eBudgetDiff) { | |||
354 | //set the legend text | 354 | //set the legend text | ||
355 | legend->setText(rowNum, legendText); | 355 | legend->setText(rowNum, legendText); | ||
356 | 356 | | |||
357 | //clear to speed up drawPivotRowSet | 357 | //clear to speed up drawPivotRowSet | ||
358 | if (!config.isChartDataLabels()) | 358 | if (!config.isChartDataLabels()) | ||
359 | legendText.clear(); | 359 | legendText.clear(); | ||
360 | 360 | | |||
361 | //set the cell value and tooltip | 361 | //set the cell value and tooltip | ||
362 | rowNum = drawPivotRowSet(QString(), rowNum, (*it_innergroup).m_total, rowTypeList[i], legendText, 1, numColumns() - 1); | 362 | rowNum = drawPivotRowSet(QString(), rowNum, (*it_innergroup).m_total, rowTypeList[i], legendText, 0, numColumns()); | ||
363 | } | 363 | } | ||
364 | } | 364 | } | ||
365 | ++it_innergroup; | 365 | ++it_innergroup; | ||
366 | } | 366 | } | ||
367 | ++it_outergroup; | 367 | ++it_outergroup; | ||
368 | } | 368 | } | ||
369 | } | 369 | } | ||
370 | break; | 370 | break; | ||
Show All 20 Lines | 381 | if (rowTypeList[i] != eBudgetDiff) { | |||
391 | //set the legend text | 391 | //set the legend text | ||
392 | legend->setText(rowNum, legendText); | 392 | legend->setText(rowNum, legendText); | ||
393 | 393 | | |||
394 | //clear to speed up drawPivotRowSet | 394 | //clear to speed up drawPivotRowSet | ||
395 | if (!config.isChartDataLabels()) | 395 | if (!config.isChartDataLabels()) | ||
396 | legendText.clear(); | 396 | legendText.clear(); | ||
397 | 397 | | |||
398 | //set the cell value and tooltip | 398 | //set the cell value and tooltip | ||
399 | rowNum = drawPivotRowSet(QString(), rowNum, (*it_outergroup).m_total, rowTypeList[i], legendText, 1, numColumns() - 1); | 399 | rowNum = drawPivotRowSet(QString(), rowNum, (*it_outergroup).m_total, rowTypeList[i], legendText, 0, numColumns()); | ||
400 | } | 400 | } | ||
401 | } | 401 | } | ||
402 | ++it_outergroup; | 402 | ++it_outergroup; | ||
403 | } | 403 | } | ||
404 | 404 | | |||
405 | //if selected, show totals too | 405 | //if selected, show totals too | ||
406 | if (config.isShowingRowTotals()) { | 406 | if (config.isShowingRowTotals()) { | ||
407 | //iterate row types | 407 | //iterate row types | ||
Show All 11 Lines | 410 | if (rowTypeList[i] != eBudgetDiff) { | |||
419 | //set the legend text | 419 | //set the legend text | ||
420 | legend->setText(rowNum, legendText); | 420 | legend->setText(rowNum, legendText); | ||
421 | 421 | | |||
422 | //clear to speed up drawPivotRowSet | 422 | //clear to speed up drawPivotRowSet | ||
423 | if (!config.isChartDataLabels()) | 423 | if (!config.isChartDataLabels()) | ||
424 | legendText.clear(); | 424 | legendText.clear(); | ||
425 | 425 | | |||
426 | //set the cell value | 426 | //set the cell value | ||
427 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 1, numColumns() - 1); | 427 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 0, numColumns()); | ||
428 | } | 428 | } | ||
429 | } | 429 | } | ||
430 | } | 430 | } | ||
431 | } | 431 | } | ||
432 | break; | 432 | break; | ||
433 | 433 | | |||
434 | case MyMoneyReport::eDetailTotal: { | 434 | case MyMoneyReport::eDetailTotal: { | ||
435 | int rowNum = 0; | 435 | int rowNum = 0; | ||
Show All 14 Lines | 440 | if (rowTypeList[i] != eBudgetDiff) { | |||
450 | legend->setText(rowNum, legendText); | 450 | legend->setText(rowNum, legendText); | ||
451 | 451 | | |||
452 | //clear to speed up drawPivotRowSet | 452 | //clear to speed up drawPivotRowSet | ||
453 | if (!config.isChartDataLabels()) | 453 | if (!config.isChartDataLabels()) | ||
454 | legendText.clear(); | 454 | legendText.clear(); | ||
455 | 455 | | |||
456 | if (config.isMixedTime() && (rowTypeList[i] == eActual || rowTypeList[i] == eForecast)) { | 456 | if (config.isMixedTime() && (rowTypeList[i] == eActual || rowTypeList[i] == eForecast)) { | ||
457 | if (rowTypeList[i] == eActual) { | 457 | if (rowTypeList[i] == eActual) { | ||
458 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 1, config.currentDateColumn()); | 458 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 0, config.currentDateColumn()); | ||
459 | } else if (rowTypeList[i] == eForecast) { | 459 | } else if (rowTypeList[i] == eForecast) { | ||
460 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, config.currentDateColumn(), numColumns() - 1); | 460 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, config.currentDateColumn(), numColumns() - config.currentDateColumn()); | ||
461 | } else { | 461 | } else { | ||
462 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 1, numColumns() - 1); | 462 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 0, numColumns()); | ||
463 | } | 463 | } | ||
464 | } else { | 464 | } else { | ||
465 | //set cell value | 465 | //set cell value | ||
466 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 1, numColumns() - 1); | 466 | rowNum = drawPivotRowSet(QString(), rowNum, grid.m_total, rowTypeList[i], legendText, 0, numColumns()); | ||
467 | } | 467 | } | ||
468 | } | 468 | } | ||
469 | } | 469 | } | ||
470 | } | 470 | } | ||
471 | break; | 471 | break; | ||
472 | } | 472 | } | ||
473 | m_model.blockSignals(blocked); // reenable dataChanged() signal | 473 | m_model.blockSignals(blocked); // reenable dataChanged() signal | ||
474 | 474 | | |||
475 | if (config.chartType() == MyMoneyReport::eChartLine || | 475 | if (config.chartType() == MyMoneyReport::eChartLine || | ||
476 | config.chartType() == MyMoneyReport::eChartBar || | 476 | config.chartType() == MyMoneyReport::eChartBar || | ||
477 | config.chartType() == MyMoneyReport::eChartStackedBar) { | 477 | config.chartType() == MyMoneyReport::eChartStackedBar) { | ||
478 | // Set up X axis labels (ie "abscissa" to use the technical term) | 478 | // Set up X axis labels (ie "abscissa" to use the technical term) | ||
479 | QStringList abscissaNames; | 479 | QStringList abscissaNames; | ||
480 | if (accountSeries()) { // if not, we will set these up while putting in the chart values. | 480 | if (accountSeries()) { // if not, we will set these up while putting in the chart values. | ||
481 | int column = 1; | 481 | int column = 0; | ||
482 | while (column < numColumns()) { | 482 | while (column < numColumns()) { | ||
483 | abscissaNames += QString(columnHeadings[column++]).replace(" ", " "); | 483 | abscissaNames += QString(columnHeadings[column++]).replace(" ", " "); | ||
484 | } | 484 | } | ||
485 | qDebug() << "rows: " << m_model.rowCount() << "columns: " << m_model.columnCount(); | 485 | qDebug() << "rows: " << m_model.rowCount() << "columns: " << m_model.columnCount(); | ||
486 | m_model.setVerticalHeaderLabels(abscissaNames); | 486 | m_model.setVerticalHeaderLabels(abscissaNames); | ||
487 | } | 487 | } | ||
488 | } | 488 | } | ||
489 | 489 | | |||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 554 | { | |||
590 | if (lineDiagram) | 590 | if (lineDiagram) | ||
591 | lineDiagram->axes().at(1)->setLabels(labels); | 591 | lineDiagram->axes().at(1)->setLabels(labels); | ||
592 | 592 | | |||
593 | KChart::BarDiagram* barDiagram = qobject_cast<BarDiagram*>(coordinatePlane()->diagram()); | 593 | KChart::BarDiagram* barDiagram = qobject_cast<BarDiagram*>(coordinatePlane()->diagram()); | ||
594 | if (barDiagram) | 594 | if (barDiagram) | ||
595 | barDiagram->axes().at(1)->setLabels(labels); | 595 | barDiagram->axes().at(1)->setLabels(labels); | ||
596 | } | 596 | } | ||
597 | 597 | | |||
598 | unsigned KReportChartView::drawPivotRowSet(const QString& rowAcc, int rowNum, const PivotGridRowSet& rowSet, const ERowType rowType, const QString& legendText, int startColumn, int endColumn) | 598 | unsigned KReportChartView::drawPivotRowSet(const QString& rowAcc, int rowNum, const PivotGridRowSet& rowSet, const ERowType rowType, const QString& legendText, int startColumn, int columnsToDraw) | ||
599 | { | 599 | { | ||
600 | if (coordinatePlane()->diagram()->datasetDimension() != 1) | 600 | if (coordinatePlane()->diagram()->datasetDimension() != 1) | ||
601 | return ++rowNum; | 601 | return ++rowNum; | ||
602 | //if endColumn is invalid, make it the same as numColumns | 602 | //if columnsToDraw is invalid, make it the same as numColumns | ||
603 | if (endColumn == 0) | 603 | if (columnsToDraw == 0) | ||
604 | endColumn = numColumns(); | 604 | columnsToDraw = numColumns(); | ||
605 | 605 | | |||
606 | MyMoneyFile* file = MyMoneyFile::instance(); | 606 | MyMoneyFile* file = MyMoneyFile::instance(); | ||
607 | double value; | 607 | double value; | ||
608 | QString toolTip; | 608 | QString toolTip; | ||
609 | 609 | | |||
610 | if (( accountSeries() && !seriesTotals()) || | 610 | if (( accountSeries() && !seriesTotals()) || | ||
611 | (!accountSeries() && seriesTotals())) { | 611 | (!accountSeries() && seriesTotals())) | ||
612 | justifyModelSize(endColumn > numColumns() - 1 ? endColumn + 1 : numColumns(), rowNum + 1); | 612 | justifyModelSize(columnsToDraw, rowNum + 1); | ||
613 | } else { | 613 | else | ||
614 | justifyModelSize(rowNum + 1, endColumn > numColumns() - 1 ? endColumn + 1 : numColumns()); | 614 | justifyModelSize(rowNum + 1, columnsToDraw); | ||
615 | } | | |||
616 | 615 | | |||
617 | int precision = 0; | 616 | int precision = 0; | ||
618 | if (!rowAcc.isEmpty()) { | 617 | if (!rowAcc.isEmpty()) { | ||
619 | const MyMoneyAccount acc = file->account(rowAcc); | 618 | const MyMoneyAccount acc = file->account(rowAcc); | ||
620 | if (rowType == ePrice) { | 619 | if (rowType == ePrice) { | ||
621 | if (acc.isInvest()) | 620 | if (acc.isInvest()) | ||
622 | precision = file->currency(acc.currencyId()).pricePrecision(); | 621 | precision = file->currency(acc.currencyId()).pricePrecision(); | ||
623 | } else { | 622 | } else { | ||
624 | if (acc.isInvest()) // stock account isn't eveluated in currency, so take investment account instead | 623 | if (acc.isInvest()) // stock account isn't eveluated in currency, so take investment account instead | ||
625 | precision = MyMoneyMoney::denomToPrec(file->account(acc.parentAccountId()).fraction()); | 624 | precision = MyMoneyMoney::denomToPrec(file->account(acc.parentAccountId()).fraction()); | ||
626 | else | 625 | else | ||
627 | precision = MyMoneyMoney::denomToPrec(acc.fraction()); | 626 | precision = MyMoneyMoney::denomToPrec(acc.fraction()); | ||
628 | } | 627 | } | ||
629 | } | 628 | } | ||
630 | if (precision == 0) | 629 | if (precision == 0) | ||
631 | precision = file->baseCurrency().pricePrecision(); | 630 | precision = MyMoneyMoney::denomToPrec(file->baseCurrency().smallestAccountFraction()); | ||
632 | 631 | | |||
633 | // Columns | 632 | // Columns | ||
634 | if (seriesTotals()) { | 633 | if (seriesTotals()) { | ||
635 | value = rowSet[rowType].m_total.toDouble(); | 634 | value = rowSet[rowType].m_total.toDouble(); | ||
636 | 635 | | |||
637 | //set the tooltip | 636 | //set the tooltip | ||
638 | if (!legendText.isEmpty()) | 637 | if (!legendText.isEmpty()) | ||
639 | toolTip = QString("<h2>%1</h2><strong>%2</strong><br>") | 638 | toolTip = QString("<h2>%1</h2><strong>%2</strong><br>") | ||
640 | .arg(legendText) | 639 | .arg(legendText) | ||
641 | .arg(value, 0, 'f', precision); | 640 | .arg(value, 0, 'f', precision); | ||
642 | 641 | | |||
643 | //set the cell value | 642 | //set the cell value | ||
644 | if (accountSeries()) | 643 | if (accountSeries()) | ||
645 | this->setDataCell(rowNum, 0, value, toolTip); | 644 | this->setDataCell(rowNum, 0, value, toolTip); | ||
646 | else | 645 | else | ||
647 | this->setDataCell(0, rowNum, value, toolTip); | 646 | this->setDataCell(0, rowNum, value, toolTip); | ||
648 | } else { | 647 | } else { | ||
649 | int column = startColumn; | 648 | int column = startColumn; | ||
650 | while (column <= endColumn && column < numColumns()) { | 649 | while (column <= columnsToDraw && column < numColumns()) { | ||
651 | //if zero and set to skip, increase column and continue with next value | 650 | //if zero and set to skip, increase column and continue with next value | ||
652 | if (m_skipZero && rowSet[rowType][column].isZero()) { | 651 | if (m_skipZero && rowSet[rowType][column].isZero()) { | ||
653 | ++column; | 652 | ++column; | ||
654 | continue; | 653 | continue; | ||
655 | } else { | 654 | } else { | ||
656 | value = rowSet[rowType][column].toDouble(); | 655 | value = rowSet[rowType][column].toDouble(); | ||
657 | if (!legendText.isEmpty()) | 656 | if (!legendText.isEmpty()) | ||
658 | toolTip = QString("<h2>%1</h2><strong>%2</strong><br>") | 657 | toolTip = QString("<h2>%1</h2><strong>%2</strong><br>") | ||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |