| 37 | }; |
| 38 | |
| 39 | MainWindow::MainWindow(QWidget *parent) |
| 40 | : QWidget(parent) |
| 41 | { |
| 42 | setupUi(this); |
| 43 | |
| 44 | auto *chartLayout = new QHBoxLayout(chartFrame); |
| 45 | m_chart = new KDChart::Chart(); |
| 46 | chartLayout->addWidget(m_chart); |
| 47 | |
| 48 | m_model.loadFromCSV(":/data"); |
| 49 | |
| 50 | // Set up the diagram |
| 51 | m_lines = new KDChart::LineDiagram(); |
| 52 | m_lines->setModel(&m_model); |
| 53 | m_chart->coordinatePlane()->replaceDiagram(m_lines); |
| 54 | |
| 55 | QPen pen = QPen(m_lines->pen(0).color(), 2); |
| 56 | pen.setStyle(Qt::DashLine); |
| 57 | m_lines->setPen(0, pen); |
| 58 | pen = QPen(m_lines->pen(2).color(), 2); |
| 59 | pen.setStyle(Qt::DashDotDotLine); |
| 60 | m_lines->setPen(2, pen); |
| 61 | |
| 62 | // Add at least one legend for starters |
| 63 | auto *legend = new KDChart::Legend(m_lines, m_chart); |
| 64 | legend->setPosition(KDChart::Position::North); |
| 65 | legend->setAlignment(Qt::AlignCenter); |
| 66 | legend->setShowLines(false); |
| 67 | legend->setTitleText(tr("Legend")); |
| 68 | legend->setOrientation(Qt::Vertical); |
| 69 | m_chart->addLegend(legend); |
| 70 | legend->show(); |
| 71 | |
| 72 | auto *newItem = new LegendItem(legend, legendsTV); |
| 73 | newItem->setText(0, tr("North")); |
| 74 | newItem->setText(1, tr("no")); |
| 75 | newItem->setText(2, tr("Legend")); |
| 76 | newItem->setText(3, tr("Vertical")); |
| 77 | newItem->setText(4, tr("Center")); |
| 78 | newItem->setText(5, tr("MarkersOnly")); |
| 79 | |
| 80 | alignmentMap[Qt::AlignTop | Qt::AlignLeft] = tr("Top + Left"); |
| 81 | alignmentMap[Qt::AlignTop | Qt::AlignHCenter] = tr("Top + HCenter"); |
| 82 | alignmentMap[Qt::AlignTop | Qt::AlignRight] = tr("Top + Right"); |
| 83 | alignmentMap[Qt::AlignVCenter | Qt::AlignRight] = tr("VCenter + Right"); |
| 84 | alignmentMap[Qt::AlignBottom | Qt::AlignRight] = tr("Bottom + Right"); |
| 85 | alignmentMap[Qt::AlignBottom | Qt::AlignHCenter] = tr("Bottom + HCenter"); |
| 86 | alignmentMap[Qt::AlignBottom | Qt::AlignLeft] = tr("Bottom + Left"); |
| 87 | alignmentMap[Qt::AlignVCenter | Qt::AlignLeft] = tr("VCenter + Left"); |
| 88 | alignmentMap[Qt::AlignCenter] = tr("Center"); |
| 89 | |
| 90 | m_chart->update(); |
| 91 | } |
| 92 | |
| 93 | void MainWindow::initAddLegendDialog(DerivedAddLegendDialog &conf, |
| 94 | Qt::Alignment alignment) const |
nothing calls this directly
no test coverage detected