File indexing completed on 2024-04-14 03:40:17

0001 /*
0002     NumerationItem - Numeration Item, part of the Periodic Table Graphics View
0003     for Kalzium
0004 
0005     SPDX-FileCopyrightText: 2007-2009 Marcus D. Hanwell <marcus@cryos.org>
0006     SPDX-FileCopyrightText: 2010 Etienne Rebetez <etienne.rebetez@oberwallis.ch>
0007 
0008     This file is part of the Avogadro molecular editor project.
0009     For more information, see <https://avogadro.cc/>
0010 
0011     SPDX-License-Identifier: LGPL-2.1-or-later
0012 */
0013 
0014 #ifndef NUMERATIONITEM_H
0015 #define NUMERATIONITEM_H
0016 
0017 #include <QGraphicsItem>
0018 
0019 #include <chemicaldataobject.h>
0020 
0021 /**
0022  * @class NumerationItem
0023  * @author Marcus D. Hanwell
0024  * @author Etienne Rebetez
0025  * @brief An Numeration item, intended to display a id of the numeration row.
0026  *
0027  */
0028 class NumerationItem : public QGraphicsObject
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     /**
0034      * Constructor. Should be called with the element number for this item. The
0035      * constructor uses setData to set the element number using the key 0. This
0036      * is then used by PeriodicTable to figure out which element was clicked on.
0037      */
0038     explicit NumerationItem(int xPosition = 0);
0039 
0040     /**
0041      * Destructor.
0042      */
0043     ~NumerationItem() override;
0044 
0045     /**
0046      * @return the bounding rectangle of the element item.
0047      */
0048     QRectF boundingRect() const override;
0049 
0050     /**
0051      * @return the painter path which is also a rectangle in this case.
0052      */
0053     QPainterPath shape() const override;
0054 
0055     /**
0056      * This is where most of the action takes place. The element box is drawn
0057      * along with its symbol.
0058      */
0059     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
0060 
0061 public Q_SLOTS:
0062     void setNumerationType(int type);
0063 
0064 private:
0065     /**
0066      * Width of the elements.
0067      */
0068     int m_width;
0069 
0070     /**
0071      * Height of the elements.
0072      */
0073     int m_height;
0074 
0075     /**
0076      * The row Position of the Numeration item
0077      */
0078     int m_xPosition;
0079 
0080     /**
0081      * The numeration symbol.
0082      */
0083     QString m_numeration;
0084 
0085     /**
0086      * The type of the element.
0087      */
0088     int m_type;
0089 };
0090 
0091 #endif // NUMERATIONITEM_H