Warning, file /libraries/baloo-widgets/test/tagwidgettest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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     m_tagWidget = new Baloo::TagWidget(this);
0017     auto lay = new QVBoxLayout(this);
0018     lay->addWidget(m_tagWidget);
0019     connect(m_tagWidget, SIGNAL(tagClicked(QString)), this, SLOT(slotTagClicked(QString)));
0020     connect(m_tagWidget, SIGNAL(selectionChanged(QStringList)), this, SLOT(slotSelectionChanged(QStringList)));
0021 
0022     auto box = new QCheckBox(QStringLiteral("Align Right"), this);
0023     connect(box, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool)));
0024     lay->addWidget(box);
0025 
0026     box = new QCheckBox(QStringLiteral("Read only"), this);
0027     connect(box, SIGNAL(toggled(bool)), this, SLOT(setReadOnly(bool)));
0028     lay->addWidget(box);
0029 }
0030 
0031 TagWidgetTest::~TagWidgetTest() = default;
0032 
0033 void TagWidgetTest::slotTagClicked(const QString &tag)
0034 {
0035     qDebug() << "Tag clicked:" << tag;
0036 }
0037 
0038 void TagWidgetTest::slotSelectionChanged(const QStringList &tags)
0039 {
0040     qDebug() << "Selection changed:" << tags;
0041 }
0042 
0043 void TagWidgetTest::alignRight(bool enable)
0044 {
0045     if (enable)
0046         m_tagWidget->setAlignment(Qt::AlignRight);
0047     else
0048         m_tagWidget->setAlignment(Qt::AlignLeft);
0049 }
0050 
0051 void TagWidgetTest::setReadOnly(bool enable)
0052 {
0053     m_tagWidget->setReadyOnly(enable);
0054 }