1 /* Copyright (C) 2012 Mildred <mildred-pub@mildred.fr>
2 Copyright (C) 2015 Erik Quaeghebeur <trojita@equaeghe.nospammail.net>
3 Copyright (C) 2006 - 2015 Jan Kundrát <jkt@kde.org>
5 This file is part of the Trojita Qt IMAP e-mail client,
6 http://trojita.flaska.net/
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License or (at your option) version 3 or any later version
12 accepted by the membership of KDE e.V. (or its successor approved
13 by the membership of KDE e.V.), which shall act as a proxy
14 defined in Section 14 of version 3 of the license.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "TagWidget.h"
33 TagWidget::TagWidget(const Mode mode
, const QString
&tagName
, const QString
&backgroundColor
):
38 setStyleSheet(QString::fromLatin1("border: 1px solid black; border-radius: 4px; background-color: %1;").arg(backgroundColor
));
41 TagWidget
*TagWidget::addingWidget()
43 auto res
= new TagWidget(Mode::AddingWidget
, QString(), QStringLiteral("lightgreen"));
44 res
->setText(QStringLiteral("+"));
48 TagWidget
*TagWidget::userKeyword(const QString
&tagName
)
50 auto res
= new TagWidget(Mode::UserKeyword
, tagName
, QStringLiteral("lightyellow"));
51 res
->setText(tagName
+ QLatin1String(" | x"));
55 TagWidget
*TagWidget::systemFlag(const QString
&flagName
)
57 auto res
= new TagWidget(Mode::SystemFlag
, flagName
, QStringLiteral("lightgrey"));
58 res
->setText(flagName
);
62 bool TagWidget::event(QEvent
*e
)
64 if (e
->type() == QEvent::MouseButtonPress
) {
66 case Mode::AddingWidget
:
69 case Mode::UserKeyword
:
70 Q_ASSERT(!m_tagName
.isEmpty());
71 emit
removeClicked(m_tagName
);
73 case Mode::SystemFlag
:
74 // do nothing -- this is just an indicator
79 return QLabel::event(e
);
82 QString
TagWidget::tagName() const