1 | /* |
2 | Copyright (c) 2010-2011 Sune Vuorela <sune@vuorela.dk> |
3 | |
4 | Permission is hereby granted, free of charge, to any person |
5 | obtaining a copy of this software and associated documentation |
6 | files (the "Software"), to deal in the Software without |
7 | restriction, including without limitation the rights to use, |
8 | copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 | copies of the Software, and to permit persons to whom the |
10 | Software is furnished to do so, subject to the following |
11 | conditions: |
12 | |
13 | The above copyright notice and this permission notice shall be |
14 | included in all copies or substantial portions of the Software. |
15 | |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
23 | OTHER DEALINGS IN THE SOFTWARE. |
24 | |
25 | */ |
26 | |
27 | #ifndef PRISON_BARCODEWIDGET_H |
28 | #define PRISON_BARCODEWIDGET_H |
29 | |
30 | #include <QWidget> |
31 | #include <prison/prison_export.h> |
32 | |
33 | |
34 | namespace prison { |
35 | class AbstractBarcode; |
36 | /** |
37 | * QWidget with a barcode on |
38 | */ |
39 | |
40 | class PRISON_EXPORT BarcodeWidget : public QWidget { |
41 | public: |
42 | /** |
43 | * Creates a barcodewidget with no barcode generator |
44 | * use setBarcode() to set the barcode |
45 | * @param parent the parent in QWidget hierachy |
46 | */ |
47 | BarcodeWidget(QWidget* parent=0); |
48 | /** |
49 | * Creates a barcode widget with 'barcode' as barcode generator |
50 | * @param barcode The barcode generator for this widget. Takes ownership over the barcode generator |
51 | * @param parent the parent in QWidget hierachy |
52 | */ |
53 | BarcodeWidget(AbstractBarcode* barcode, QWidget* parent=0); |
54 | virtual ~BarcodeWidget(); |
55 | /** |
56 | * sets the data shown to data, and triggers a repaint and resize if needed |
57 | * @param data QString holding the data to be shown |
58 | */ |
59 | void setData(QString data); |
60 | /** |
61 | * sets the barcode generator to barcode, and deletes the existing barcode. |
62 | * @param barcode USes this barcode generator for this widget, and takes ownership over it |
63 | */ |
64 | void setBarcode(AbstractBarcode* barcode); |
65 | /** |
66 | * Reimplementation |
67 | * @return minimumSizeHint for this widget |
68 | */ |
69 | virtual QSize minimumSizeHint() const; |
70 | protected: |
71 | /** |
72 | * paintEvent |
73 | * @param event QPaintEvent |
74 | */ |
75 | virtual void paintEvent(QPaintEvent* event ); |
76 | /** |
77 | * resizeEvent |
78 | * @param event QResizeEvent |
79 | */ |
80 | virtual void resizeEvent(QResizeEvent* event ); |
81 | /** |
82 | * enables drag from the barcodewidget |
83 | * @param event QMouseEvent |
84 | */ |
85 | virtual void mousePressEvent(QMouseEvent* event); |
86 | private: |
87 | class Private; |
88 | /** |
89 | * d pointer |
90 | */ |
91 | Private* d; |
92 | }; |
93 | }; //namespace |
94 | |
95 | #endif // PRISON_BARCODEWIDGET_H |
96 | |