| 351 | |
| 352 | |
| 353 | HeaderWidget::HeaderWidget(QWidget* parent, const Headers& header) : QWidget(parent) |
| 354 | { |
| 355 | QGridLayout* layout = new QGridLayout(); |
| 356 | layout->setContentsMargins(0, 0, 0, 0); |
| 357 | layout->setVerticalSpacing(1); |
| 358 | int row = 0; |
| 359 | int col = 0; |
| 360 | for (auto& field : header.GetFields()) |
| 361 | { |
| 362 | layout->addWidget(new QLabel(field.title + ": "), row, col * 3); |
| 363 | for (auto& value : field.values) |
| 364 | { |
| 365 | QWidget* label; |
| 366 | if (field.type == AddressHeaderField) |
| 367 | { |
| 368 | label = new NavigationAddressLabel(value); |
| 369 | } |
| 370 | else if (field.type == CodeHeaderField) |
| 371 | { |
| 372 | label = new NavigationCodeLabel(value); |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | label = new QLabel(value); |
| 377 | label->setFont(getMonospaceFont(this)); |
| 378 | } |
| 379 | layout->addWidget(label, row, col * 3 + 1); |
| 380 | row++; |
| 381 | } |
| 382 | if ((header.GetColumns() > 1) && (row >= (int)header.GetRowsPerColumn()) |
| 383 | && ((col + 1) < (int)header.GetColumns())) |
| 384 | { |
| 385 | row = 0; |
| 386 | col++; |
| 387 | } |
| 388 | } |
| 389 | for (col = 1; col < (int)header.GetColumns(); col++) |
| 390 | layout->setColumnMinimumWidth(col * 3 - 1, UIContext::getScaledWindowSize(20, 20).width()); |
| 391 | layout->setColumnStretch((int)header.GetColumns() * 3 - 1, 1); |
| 392 | setLayout(layout); |
| 393 | } |
no test coverage detected