File indexing completed on 2024-05-05 16:21:39

0001 /*
0002     SPDX-FileCopyrightText: 2010-2014 Sune Vuorela <sune@vuorela.dk>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef PRISON_BARCODEWIDGET_H
0008 #define PRISON_BARCODEWIDGET_H
0009 
0010 #include <QWidget>
0011 
0012 namespace Prison
0013 {
0014 class AbstractBarcode;
0015 }
0016 /**
0017  * QWidget with a barcode on
0018  */
0019 class BarcodeExampleWidget : public QWidget
0020 {
0021 public:
0022     /**
0023      * Creates a barcode widget with 'barcode' as barcode generator
0024      * @param barcode The barcode generator for this widget. Takes ownership over the barcode generator
0025      * @param parent the parent in QWidget hierarchy
0026      */
0027     BarcodeExampleWidget(Prison::AbstractBarcode *barcode, QWidget *parent = nullptr);
0028     ~BarcodeExampleWidget() override;
0029     /**
0030      * sets the data shown to data, and triggers a repaint and resize if needed
0031      * @param data QString holding the data to be shown
0032      */
0033     void setData(const QString &data);
0034     /**
0035      * Reimplementation
0036      * @return minimumSizeHint for this widget
0037      */
0038     QSize minimumSizeHint() const override;
0039 
0040 protected:
0041     /**
0042      * paintEvent
0043      * @param event QPaintEvent
0044      */
0045     void paintEvent(QPaintEvent *event) override;
0046     /**
0047      * resizeEvent
0048      * @param event QResizeEvent
0049      */
0050     void resizeEvent(QResizeEvent *event) override;
0051     /**
0052      * enables drag from the barcodewidget
0053      * @param event QMouseEvent
0054      */
0055     void mousePressEvent(QMouseEvent *event) override;
0056 
0057 private:
0058     Prison::AbstractBarcode *m_barcode;
0059 };
0060 
0061 #endif // PRISON_BARCODEWIDGET_H