Prison

scanresult.h
1 /*
2  SPDX-FileCopyrightText: 2022 Volker Krause <[email protected]>
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 
17 namespace Prison
18 {
19 
20 class 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  */
30 class 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 
45 public:
46  explicit ScanResult();
47  ScanResult(const ScanResult &);
48  ~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 
83 private:
84  friend class ScanResultPrivate;
86 };
87 
88 }
89 
90 Q_DECLARE_METATYPE(Prison::ScanResult)
91 
92 #endif // PRISON_SCANRESULT_H
BarcodeFormat
Barcode formats.
Definition: format.h:27
Result of a barcode scan attempt.
Definition: scanresult.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 03:59:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.