File indexing completed on 2024-04-14 04:35:09
0001 /* 0002 SPDX-FileCopyrightText: 2010 Sebastian Trueg <trueg@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "tagwidgettest.h" 0008 0009 #include <QCheckBox> 0010 #include <QDebug> 0011 #include <QVBoxLayout> 0012 0013 TagWidgetTest::TagWidgetTest() 0014 : QWidget() 0015 { 0016 using TagWidget = Baloo::TagWidget; 0017 0018 m_tagWidget = new TagWidget(this); 0019 auto lay = new QVBoxLayout(this); 0020 lay->addWidget(m_tagWidget); 0021 connect(m_tagWidget, &TagWidget::tagClicked, this, &TagWidgetTest::slotTagClicked); 0022 connect(m_tagWidget, &TagWidget::selectionChanged, this, &TagWidgetTest::slotSelectionChanged); 0023 0024 auto box = new QCheckBox(QStringLiteral("Align Right"), this); 0025 connect(box, &QCheckBox::toggled, this, &TagWidgetTest::alignRight); 0026 lay->addWidget(box); 0027 0028 box = new QCheckBox(QStringLiteral("Read only"), this); 0029 connect(box, &QCheckBox::toggled, m_tagWidget, &TagWidget::setReadyOnly); 0030 lay->addWidget(box); 0031 0032 m_tagWidget->setSelectedTags({}); 0033 } 0034 0035 TagWidgetTest::~TagWidgetTest() = default; 0036 0037 void TagWidgetTest::slotTagClicked(const QString &tag) 0038 { 0039 qDebug() << "Tag clicked:" << tag; 0040 } 0041 0042 void TagWidgetTest::slotSelectionChanged(const QStringList &tags) 0043 { 0044 qDebug() << "Selection changed:" << tags; 0045 } 0046 0047 void TagWidgetTest::alignRight(bool enable) 0048 { 0049 if (enable) 0050 m_tagWidget->setAlignment(Qt::AlignRight); 0051 else 0052 m_tagWidget->setAlignment(Qt::AlignLeft); 0053 } 0054 0055 #include "moc_tagwidgettest.cpp"