File indexing completed on 2025-04-13 09:35:15
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com> 0004 SPDX-FileCopyrightText: 2018-2022 Alexander Semke <alexander.semke@web.de> 0005 */ 0006 0007 #ifndef WORKSHEETVIEW_H 0008 #define WORKSHEETVIEW_H 0009 0010 #include <QGraphicsView> 0011 0012 class QParallelAnimationGroup; 0013 class QPropertyAnimation; 0014 0015 class Worksheet; 0016 0017 class WorksheetView : public QGraphicsView 0018 { 0019 Q_OBJECT 0020 public: 0021 WorksheetView(Worksheet*, QWidget*); 0022 0023 void makeVisible(const QRectF&); 0024 bool isVisible(const QRectF&) const; 0025 bool isAtEnd() const; 0026 void scrollToEnd() const; 0027 void scrollBy(int dy); 0028 void scrollTo(int y); 0029 0030 QPoint viewCursorPos() const; 0031 QPointF sceneCursorPos() const; 0032 QRectF viewRect() const; 0033 qreal scaleFactor() const; 0034 void setScaleFactor(qreal scale, bool emitSignal = true); 0035 void updateSceneSize(); 0036 0037 Q_SIGNALS: 0038 void viewRectChanged(QRectF) const; 0039 void scaleFactorChanged(double scale); 0040 0041 public Q_SLOTS: 0042 void zoomIn(); 0043 void zoomOut(); 0044 void actualSize(); 0045 void endAnimation(); 0046 void sceneRectChanged(const QRectF&) const; 0047 void sendViewRectChange() const; 0048 0049 private: 0050 void resizeEvent(QResizeEvent*) override; 0051 void focusInEvent(QFocusEvent*) override; 0052 void focusOutEvent(QFocusEvent*) override; 0053 void wheelEvent(QWheelEvent*) override; 0054 0055 void zoom(int); 0056 void scalingTime(); 0057 void animFinished(); 0058 0059 qreal m_scale = 1.; 0060 int m_numScheduledScalings{0}; 0061 QParallelAnimationGroup* m_animation{nullptr}; 0062 QPropertyAnimation* m_hAnimation{nullptr}; 0063 QPropertyAnimation* m_vAnimation{nullptr}; 0064 Worksheet* m_worksheet; 0065 }; 0066 0067 #endif //WORKSHEETVIEW_H