File indexing completed on 2024-05-12 04:01:32

0001 /*
0002     SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: MIT
0004 */
0005 
0006 #include "scanresult.h"
0007 #include "scanresult_p.h"
0008 
0009 using namespace Prison;
0010 
0011 ScanResult::ScanResult()
0012     : d(new ScanResultPrivate)
0013 {
0014 }
0015 
0016 ScanResult::ScanResult(const ScanResult &) = default;
0017 ScanResult::~ScanResult() = default;
0018 ScanResult &ScanResult::operator=(const ScanResult &) = default;
0019 
0020 bool ScanResult::operator==(const ScanResult &other) const
0021 {
0022     return d->content == other.d->content && d->boundingRect == other.d->boundingRect && d->format == other.d->format;
0023 }
0024 
0025 bool ScanResult::hasContent() const
0026 {
0027     return !d->content.isNull();
0028 }
0029 
0030 QVariant ScanResult::content() const
0031 {
0032     return d->content;
0033 }
0034 
0035 bool ScanResult::hasText() const
0036 {
0037     return d->content.userType() == QMetaType::QString;
0038 }
0039 
0040 QString ScanResult::text() const
0041 {
0042     return hasText() ? d->content.toString() : QString();
0043 }
0044 
0045 bool ScanResult::hasBinaryData() const
0046 {
0047     return d->content.userType() == QMetaType::QByteArray;
0048 }
0049 
0050 QByteArray ScanResult::binaryData() const
0051 {
0052     return hasBinaryData() ? d->content.toByteArray() : QByteArray();
0053 }
0054 
0055 Format::BarcodeFormat ScanResult::format() const
0056 {
0057     return d->format;
0058 }
0059 
0060 QRect ScanResult::boundingRect() const
0061 {
0062     return d->boundingRect;
0063 }
0064 
0065 #include "moc_scanresult.cpp"