File indexing completed on 2024-05-19 05:28:48

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include "breezebaseengine.h"
0010 #include "breezedatamap.h"
0011 #include "breezeheaderviewdata.h"
0012 
0013 namespace Breeze
0014 {
0015 //* stores headerview hovered action and timeLine
0016 class HeaderViewEngine : public BaseEngine
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     //* constructor
0022     explicit HeaderViewEngine(QObject *parent)
0023         : BaseEngine(parent)
0024     {
0025     }
0026 
0027     //* register headerview
0028     bool registerWidget(QWidget *);
0029 
0030     //* true if widget hover state is changed
0031     bool updateState(const QObject *, const QPoint &, bool);
0032 
0033     //* true if widget is animated
0034     bool isAnimated(const QObject *object, const QPoint &point)
0035     {
0036         if (DataMap<HeaderViewData>::Value data = _data.find(object)) {
0037             if (Animation::Pointer animation = data.data()->animation(point)) {
0038                 return animation.data()->isRunning();
0039             }
0040         }
0041         return false;
0042     }
0043 
0044     //* animation opacity
0045     qreal opacity(const QObject *object, const QPoint &point)
0046     {
0047         return isAnimated(object, point) ? _data.find(object).data()->opacity(point) : AnimationData::OpacityInvalid;
0048     }
0049 
0050     //* enability
0051     void setEnabled(bool value) override
0052     {
0053         BaseEngine::setEnabled(value);
0054         _data.setEnabled(value);
0055     }
0056 
0057     //* duration
0058     void setDuration(int value) override
0059     {
0060         BaseEngine::setDuration(value);
0061         _data.setDuration(value);
0062     }
0063 
0064 public Q_SLOTS:
0065 
0066     //* remove widget from map
0067     bool unregisterWidget(QObject *object) override
0068     {
0069         return _data.unregisterWidget(object);
0070     }
0071 
0072 private:
0073     //* data map
0074     DataMap<HeaderViewData> _data;
0075 };
0076 
0077 }