File indexing completed on 2025-03-23 03:29:08
0001 /* 0002 PeriodicTableScene - Periodic Table Graphics Scene for Kalzium 0003 0004 SPDX-FileCopyrightText: 2005-2006 Pino Toscano <toscano.pino@tiscali.it> 0005 SPDX-FileCopyrightText: 2003-2006 Carsten Niehaus <cniehaus@kde.org> 0006 SPDX-FileCopyrightText: 2007-2009 Marcus D. Hanwell <marcus@cryos.org> 0007 SPDX-FileCopyrightText: 2010 Etienne Rebetez <etienne.rebetez@oberwallis.ch> 0008 0009 SPDX-License-Identifier: LGPL-2.1-or-later 0010 */ 0011 0012 #ifndef PERIODICTABLESCENE_H 0013 #define PERIODICTABLESCENE_H 0014 0015 #include <QGraphicsScene> 0016 #include <QPointF> 0017 #include <QTimer> 0018 0019 #include "elementitem.h" 0020 0021 /** 0022 * @class PeriodicTableScene 0023 * @author Marcus D. Hanwell 0024 * @brief This class encapsulates the scene, all items are contained in it. 0025 * 0026 * This class implements a QGraphicsScene that holds all of the element items. 0027 * Any items owned by this class are automatically deleted by it. 0028 */ 0029 class PeriodicTableScene : public QGraphicsScene 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit PeriodicTableScene(QObject *parent = nullptr); 0035 ~PeriodicTableScene() override; 0036 0037 Q_SIGNALS: 0038 /** 0039 * This signal is emitted when an element item is released. 0040 */ 0041 void elementChanged(int element); 0042 /** 0043 * This signal is emitted when an element item is hovered. 0044 */ 0045 void elementHovered(int element); 0046 /** 0047 * This signal is emitted when no element was clicked. 0048 */ 0049 void freeSpaceClick(); 0050 0051 private Q_SLOTS: 0052 void slotMouseover(); 0053 0054 private: 0055 QTimer m_hoverTimer; 0056 int m_prevHoverElement; 0057 QPointF m_eventPos; 0058 0059 protected: 0060 bool event(QEvent *e) override; 0061 void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 0062 void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; 0063 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; 0064 }; 0065 0066 #endif // PERIODICTABLESCENE_H