MCPcopy Create free account
hub / github.com/KDAB/KDChart / createLayouts

Method createLayouts

src/KDChart/KDChartChart.cpp:962–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

960}
961
962void Chart::Private::createLayouts()
963{
964 // The toplevel layout provides the left and right global margins
965 layout = new QHBoxLayout(chart);
966 layout->setContentsMargins(0, 0, 0, 0);
967 layout->setObjectName(QString::fromLatin1("Chart::Private::layout"));
968 layout->addSpacing(globalLeadingLeft);
969 leftOuterSpacer = layout->itemAt(layout->count() - 1)->spacerItem();
970
971 // The vLayout provides top and bottom global margins and lays
972 // out headers, footers and the diagram area.
973 vLayout = new QVBoxLayout();
974 vLayout->setContentsMargins(0, 0, 0, 0);
975 vLayout->setObjectName(QString::fromLatin1("vLayout"));
976
977 layout->addLayout(vLayout, 1000);
978 layout->addSpacing(globalLeadingRight);
979 rightOuterSpacer = layout->itemAt(layout->count() - 1)->spacerItem();
980
981 // 1. the spacing above the header area
982 vLayout->addSpacing(globalLeadingTop);
983 topOuterSpacer = vLayout->itemAt(vLayout->count() - 1)->spacerItem();
984 // 2. the header area
985 headerLayout = new QGridLayout();
986 headerLayout->setContentsMargins(0, 0, 0, 0);
987 vLayout->addLayout(headerLayout);
988 // 3. the area containing coordinate planes, axes, and legends
989 dataAndLegendLayout = new QGridLayout();
990 dataAndLegendLayout->setContentsMargins(0, 0, 0, 0);
991 dataAndLegendLayout->setObjectName(QString::fromLatin1("dataAndLegendLayout"));
992 vLayout->addLayout(dataAndLegendLayout, 1000);
993 // 4. the footer area
994 footerLayout = new QGridLayout();
995 footerLayout->setContentsMargins(0, 0, 0, 0);
996 footerLayout->setObjectName(QString::fromLatin1("footerLayout"));
997 vLayout->addLayout(footerLayout);
998
999 // 5. Prepare the header / footer layout cells:
1000 // Each of the 9 header cells (the 9 footer cells)
1001 // contain their own QVBoxLayout
1002 // since there can be more than one header (footer) per cell.
1003 for (int row = 0; row < 3; ++row) {
1004 for (int column = 0; column < 3; ++column) {
1005 const Qt::Alignment align = s_gridAlignments[row][column];
1006 for (int headOrFoot = 0; headOrFoot < 2; headOrFoot++) {
1007 auto *innerLayout = new QVBoxLayout();
1008 innerLayout->setContentsMargins(0, 0, 0, 0);
1009 innerLayout->setAlignment(align);
1010 innerHdFtLayouts[headOrFoot][row][column] = innerLayout;
1011
1012 QGridLayout *outerLayout = headOrFoot == 0 ? headerLayout : footerLayout;
1013 outerLayout->addLayout(innerLayout, row, column, align);
1014 }
1015 }
1016 }
1017
1018 // 6. the spacing below the footer area
1019 vLayout->addSpacing(globalLeadingBottom);

Callers 1

ChartMethod · 0.80

Calls 1

setAlignmentMethod · 0.45

Tested by

no test coverage detected