File indexing completed on 2024-05-19 16:31:57

0001 /*
0002  *  SPDX-FileCopyrightText: 2009 David Hubner <hubnerd@ntlworld.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  *
0006  */
0007 
0008 #include "qvlistlayout.h"
0009 
0010 #include <QLabel>
0011 #include <QStringList>
0012 
0013 QVListLayout::QVListLayout()
0014     : QVBoxLayout()
0015 {
0016 }
0017 
0018 void QVListLayout::applyQListToLayout(const QStringList &list)
0019 {
0020     bool toggle = true;
0021 
0022     QLabel *bLabel;
0023     QFont labelFont;
0024     labelFont.setBold(true);
0025 
0026     for (const QString &item : list) {
0027         if (!item.isEmpty()) {
0028             bLabel = new QLabel(item);
0029             bLabel->setWordWrap(true);
0030             if (bLabel->text() != QLatin1String("--")) {
0031                 if (toggle) {
0032                     toggle = false;
0033                     bLabel->setFont(labelFont);
0034                 } else {
0035                     bLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
0036                     bLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
0037                     bLabel->setAlignment(Qt::AlignTop);
0038                     toggle = true;
0039                 }
0040             } else {
0041                 bLabel->setText(QLatin1String(""));
0042             }
0043             addWidget(bLabel);
0044         }
0045     }
0046 }