Prison

scanresult.h
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: MIT
4*/
5
6#ifndef PRISON_SCANRESULT_H
7#define PRISON_SCANRESULT_H
8
9#include "format.h"
10#include "prisonscanner_export.h"
11
12#include <QExplicitlySharedDataPointer>
13#include <QMetaType>
14#include <QRect>
15#include <QVariant>
16
17namespace Prison
18{
19
20class ScanResultPrivate;
21
22/** Result of a barcode scan attempt.
23 *
24 * A scan result consists of the barcode content (which can be text or
25 * binary data), the barcode format and the position in the video frame
26 * the barcode was detected.
27 *
28 * @since 5.94
29 */
30class PRISONSCANNER_EXPORT ScanResult
31{
32 Q_GADGET
33 Q_PROPERTY(bool hasContent READ hasContent)
34 Q_PROPERTY(QVariant content READ content)
35
36 Q_PROPERTY(bool hasText READ hasText)
37 Q_PROPERTY(QString text READ text)
38
39 Q_PROPERTY(bool hasBinaryData READ hasBinaryData)
40 Q_PROPERTY(QByteArray binaryData READ binaryData)
41
42 Q_PROPERTY(Prison::Format::BarcodeFormat format READ format)
43 Q_PROPERTY(QRect boundingRect READ boundingRect)
44
45public:
46 explicit ScanResult();
47 ScanResult(const ScanResult &);
49 ScanResult &operator=(const ScanResult &);
50
51 bool operator==(const ScanResult &other) const;
52
53 /** Returns @c true if a barcode has been found. */
54 bool hasContent() const;
55 /** The barcode content, either a QString or a QByteArray. */
56 QVariant content() const;
57
58 /** Returns @c true if the found barcode contained a textual payload. */
59 bool hasText() const;
60 /**
61 * Returns the textual barcode content, if the content was text rather than binary data,
62 * otherwise returns an empty string.
63 */
64 QString text() const;
65
66 /** Returns @c true if the found barcode contained a binary data payload. */
67 bool hasBinaryData() const;
68 /**
69 * Returns the binary data content, if the content was binary data rather than text,
70 * otherwise returns an empty QByteArray.
71 */
72 QByteArray binaryData() const;
73
74 /** The format of the detected barcode. */
75 Format::BarcodeFormat format() const;
76
77 /** The bounding rectangle of the detected barcode in source coordinates.
78 * @note When using this to display an overlay in a view finder, this needs
79 * to be mapped to item coordinates.
80 */
81 QRect boundingRect() const;
82
83private:
84 friend class ScanResultPrivate;
86};
87
88}
89
90#endif // PRISON_SCANRESULT_H
Result of a barcode scan attempt.
Definition scanresult.h:31
BarcodeFormat
Barcode formats.
Definition format.h:27
Provides classes and methods for generating barcodes.
Definition barcode.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:55:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.