libquentier  0.5.0
The library for rich desktop clients of Evernote service
ResourceRecognitionIndexItem.h
1 /*
2  * Copyright 2016-2020 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_TYPES_RESOURCE_RECOGNITION_INDEX_ITEM_H
20 #define LIB_QUENTIER_TYPES_RESOURCE_RECOGNITION_INDEX_ITEM_H
21 
22 #include <quentier/utility/Linkage.h>
23 #include <quentier/utility/Printable.h>
24 
25 #include <QByteArray>
26 #include <QSharedDataPointer>
27 
28 namespace quentier {
29 
30 QT_FORWARD_DECLARE_CLASS(ResourceRecognitionIndexItemData)
31 
32 class QUENTIER_EXPORT ResourceRecognitionIndexItem: public Printable
33 {
34 public:
37 
38  ResourceRecognitionIndexItem & operator=(
39  const ResourceRecognitionIndexItem & other);
40 
41  virtual ~ResourceRecognitionIndexItem() override;
42 
43  bool isValid() const;
44 
45  int x() const;
46  void setX(const int x);
47 
48  int y() const;
49  void setY(const int y);
50 
51  int h() const;
52  void setH(const int h);
53 
54  int w() const;
55  void setW(const int w);
56 
57  int offset() const;
58  void setOffset(const int offset);
59 
60  int duration() const;
61  void setDuration(const int duration);
62 
63  QVector<int> strokeList() const;
64  int numStrokes() const;
65  bool strokeAt(const int strokeIndex, int & stroke) const;
66  bool setStrokeAt(const int strokeIndex, const int stroke);
67  void setStrokeList(const QVector<int> & strokeList);
68  void reserveStrokeListSpace(const int numItems);
69  void addStroke(const int stroke);
70  bool removeStroke(const int stroke);
71  bool removeStrokeAt(const int strokeIndex);
72 
73  struct TextItem
74  {
75  bool operator==(const TextItem & other) const
76  {
77  return (m_text == other.m_text) && (m_weight == other.m_weight);
78  }
79 
80  QString m_text;
81  int m_weight = -1;
82  };
83 
84  QVector<TextItem> textItems() const;
85  int numTextItems() const;
86  bool textItemAt(const int textItemIndex, TextItem & textItem) const;
87  bool setTextItemAt(const int textItemIndex, const TextItem & textItem);
88  void setTextItems(const QVector<TextItem> & textItems);
89  void reserveTextItemsSpace(const int numItems);
90  void addTextItem(const TextItem & item);
91  bool removeTextItem(const TextItem & item);
92  bool removeTextItemAt(const int textItemIndex);
93 
94  struct ObjectItem
95  {
96  bool operator==(const ObjectItem & other) const
97  {
98  return (m_objectType == other.m_objectType) &&
99  (m_weight == other.m_weight);
100  }
101 
102  QString m_objectType;
103  int m_weight = -1;
104  };
105 
106  QVector<ObjectItem> objectItems() const;
107  int numObjectItems() const;
108  bool objectItemAt(const int objectItemIndex, ObjectItem & objectItem) const;
109 
110  bool setObjectItemAt(
111  const int objectItemIndex, const ObjectItem & objectItem);
112 
113  void setObjectItems(const QVector<ObjectItem> & objectItems);
114  void reserveObjectItemsSpace(const int numItems);
115  void addObjectItem(const ObjectItem & item);
116  bool removeObjectItem(const ObjectItem & item);
117  bool removeObjectItemAt(const int objectItemIndex);
118 
119  struct ShapeItem
120  {
121  bool operator==(const ShapeItem & other) const
122  {
123  return (m_shapeType == other.m_shapeType) &&
124  (m_weight == other.m_weight);
125  }
126 
127  QString m_shapeType;
128  int m_weight = -1;
129  };
130 
131  QVector<ShapeItem> shapeItems() const;
132  int numShapeItems() const;
133  bool shapeItemAt(const int shapeItemIndex, ShapeItem & shapeItem) const;
134  bool setShapeItemAt(const int shapeItemIndex, const ShapeItem & shapeItem);
135  void setShapeItems(const QVector<ShapeItem> & shapeItems);
136  void reserveShapeItemsSpace(const int numItems);
137  void addShapeItem(const ShapeItem & item);
138  bool removeShapeItem(const ShapeItem & item);
139  bool removeShapeItemAt(const int shapeItemIndex);
140 
141  struct BarcodeItem
142  {
143  bool operator==(const BarcodeItem & other) const
144  {
145  return (m_barcode == other.m_barcode) &&
146  (m_weight == other.m_weight);
147  }
148 
149  QString m_barcode;
150  int m_weight = -1;
151  };
152 
153  QVector<BarcodeItem> barcodeItems() const;
154  int numBarcodeItems() const;
155 
156  bool barcodeItemAt(
157  const int barcodeItemIndex, BarcodeItem & barcodeItem) const;
158 
159  bool setBarcodeItemAt(
160  const int barcodeItemIndex, const BarcodeItem & barcodeItem);
161 
162  void setBarcodeItems(const QVector<BarcodeItem> & barcodeItems);
163  void reserveBarcodeItemsSpace(const int numItems);
164  void addBarcodeItem(const BarcodeItem & item);
165  bool removeBarcodeItem(const BarcodeItem & item);
166  bool removeBarcodeItemAt(const int barcodeItemIndex);
167 
168  virtual QTextStream & print(QTextStream & strm) const override;
169 
170 private:
171  QSharedDataPointer<ResourceRecognitionIndexItemData> d;
172 };
173 
174 } // namespace quentier
175 
176 #endif // LIB_QUENTIER_TYPES_RESOURCE_RECOGNITION_INDEX_ITEM_H
quentier::ResourceRecognitionIndexItem::ShapeItem
Definition: ResourceRecognitionIndexItem.h:119
quentier::Printable
The Printable class is the interface for Quentier's internal classes which should be able to write th...
Definition: Printable.h:38
quentier::ResourceRecognitionIndexItem
Definition: ResourceRecognitionIndexItem.h:32
quentier::ResourceRecognitionIndexItem::BarcodeItem
Definition: ResourceRecognitionIndexItem.h:141
quentier::ResourceRecognitionIndexItem::ObjectItem
Definition: ResourceRecognitionIndexItem.h:94
quentier::ResourceRecognitionIndexItem::TextItem
Definition: ResourceRecognitionIndexItem.h:73