File indexing completed on 2024-04-21 04:41:49

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
0003  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0004  * Copyright (C) 2010-2015 Jarosław Staniek <staniek@kde.org>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include "KReportElement.h"
0021 
0022 #include <QDebug>
0023 #include <QHash>
0024 
0025 KReportElement::~KReportElement()
0026 {
0027 }
0028 
0029 void KReportElement::setBackgroundOpacity(qreal backgroundOpacity)
0030 {
0031     d->backgroundOpacity = qMax(qMin(backgroundOpacity, 1.0), 0.0);
0032 }
0033 
0034 KREPORT_EXPORT QDebug operator<<(QDebug dbg, const KReportElement& element)
0035 {
0036     dbg.nospace() << qPrintable(
0037         QString::fromLatin1("KReportElement: name=\"%1\" rect=%2 z=%3 foregroundColor=%4 "
0038                             "backgroundColor=%5 backgroundOpacity=%6")
0039                          .arg(element.name()).arg(QVariant(element.rect()).toString())
0040                          .arg(element.z()).arg(QVariant(element.foregroundColor()).toString())
0041                          .arg(QVariant(element.backgroundColor()).toString())
0042                          .arg(element.backgroundOpacity()));
0043     return dbg.space();
0044 }
0045 
0046 KREPORT_EXPORT uint qHash(const KReportElement &element, uint seed) Q_DECL_NOTHROW
0047 {
0048     return qHash(element.name(), seed)
0049             ^ qHash(element.z(), seed)
0050             ^ qHash(element.rect().x(), seed)
0051             ^ qHash(element.foregroundColor().name(), seed)
0052             ^ qHash(element.backgroundColor().name(), seed)
0053             ^ qHash(qRound64(element.backgroundOpacity() * 1000.0), seed);
0054 }