8#include <QAbstractListModel>
11#include <QQmlParserStatus>
12#include <QRemoteObjectHost>
14#include <QVariantAnimation>
16#include "abstractanimation.h"
47class ShelfModel :
public QAbstractListModel,
public QQmlParserStatus
50 Q_INTERFACES(QQmlParserStatus)
273 explicit ShelfModel(QObject *parent =
nullptr);
639 QHash<int, QByteArray>
roleNames()
const override;
642 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
645 QVariant
headerData(
int section, Qt::Orientation orientation,
646 int role = Qt::DisplayRole)
const override;
652 QVariant
data(
const QModelIndex &proxyIndex,
int role)
const override;
658 bool setData(
const QModelIndex &index,
const QVariant &value,
659 int role = Qt::EditRole)
override;
784 inline QPair<int, int> rowIndexToRange(
const int rowIndex)
const;
785 void transitionToCurrentBrightness();
786 void syncBrightness(
bool show =
true);
787 void setRangesToColor(
const QColor &color);
788 void abortTransitions();
789 void updateLedStrip();
790 void updateAnimation();
791 void updateRemoting();
793 QPointer<LedStrip> m_ledStrip;
803 qreal m_targetBrightness;
804 bool m_animateBrightnessTransitions;
805 bool m_pendingBrightnessTransition;
806 QVariantAnimation m_brightnessTransition;
808 QColor m_averageColor;
809 bool m_animateAverageColorTransitions;
810 QVariantAnimation m_averageColorTransition;
812 int m_transitionDuration;
814 QPointer<AbstractAnimation> m_animation;
817 bool m_remotingEnabled;
818 QUrl m_listenAddress;
819 QRemoteObjectHost *m_remotingServer;
Abstract base class for LED strip animations operating on LedStrip.
Definition abstractanimation.h:29
Connects to and performs painting operations on a strip of SK9822/APA102 LEDs.
Definition ledstrip.h:45
Data model and business logic specific to the Hyelicht shelf.
Definition shelfmodel.h:48
bool animateBrightnessTransitions
Toggle animated transitions between brightness levels.
Definition shelfmodel.h:157
void brightnessChanged(qreal brightness) const
The brightness of the shelf has changed.
void setEnabled(bool enabled)
Turn the shelf on or off.
Definition shelfmodel.cpp:150
void setDensity(int density)
Set the number of LEDs in each shelf compartment.
Definition shelfmodel.cpp:273
void setColumns(int columns)
Set the number of compartments in each shelf board.
Definition shelfmodel.cpp:238
void densityChanged(int density) const
The number of LEDs in each shelf compartment has changed.
QUrl listenAddress
Listen address for the remoting API server.
Definition shelfmodel.h:256
bool enabled
Toggle the shelf on or off.
Definition shelfmodel.h:74
QVariant data(const QModelIndex &proxyIndex, int role) const override
Definition shelfmodel.cpp:691
void rowsChanged(int rows) const
The number of boards in the shelf has changed.
void setAnimating(bool animating)
Set whether to run the animation.
Definition shelfmodel.cpp:635
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition shelfmodel.cpp:679
int wallThickness
Number of LEDs behind each compartment-dividing wall.
Definition shelfmodel.h:132
bool animateAverageColorTransitions
Toggle animated transitions between full-shelf color fills.
Definition shelfmodel.h:186
void listenAddressChanged() const
The listen address for the remoting API server has changed.
void setLedStrip(LedStrip *ledStrip)
Set the LedStrip instance this model operates on.
Definition shelfmodel.cpp:100
qreal brightness
The shelf brightness level while on.
Definition shelfmodel.h:145
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition shelfmodel.cpp:739
QColor averageColor
Average color of the shelf.
Definition shelfmodel.h:174
void setAverageColor(const QColor &color)
Sets the average color of the shelf.
Definition shelfmodel.cpp:451
void setBrightness(qreal brightness)
Set the shelf brightness level while on.
Definition shelfmodel.cpp:343
void animateAverageColorTransitionsChanged(bool animate) const
Whether to animate transitions between full-shelf color fills has changed.
void setListenAddress(const QUrl &url)
Set the listen address for the remoting API server.
Definition shelfmodel.cpp:819
void animateBrightnessTransitionsChanged(bool animate) const
Whether to animate transitions between brightness levels has changed.
void setAnimateBrightnessTransitions(bool animate)
Set whether to animate transitions between brightness levels.
Definition shelfmodel.cpp:404
void transitionDurationChanged(int duration) const
The duration in milliseconds for an animated fade between brightness levels or full-shelf color fills...
int transitionDuration
Duration in milliseconds for an animated fade between brightness levels or full-shelf color fills.
Definition shelfmodel.h:203
void ledStripChanged() const
The LedStrip instance this model operates on has changed.
bool remotingEnabled
Toggle the remoting API server.
Definition shelfmodel.h:244
void wallThicknessChanged(int thickness) const
The number of LEDs behind each compartment-dividing wall has changed.
int columns
Number of compartments in each shelf board.
Definition shelfmodel.h:102
QHash< int, QByteArray > roleNames() const override
Definition shelfmodel.cpp:655
void setTransitionDuration(int duration)
Set the duration in milliseconds for an animated fade between brightness levels or full-shelf color f...
Definition shelfmodel.cpp:545
void componentComplete() override
Implements the QQmlParserStatus interface.
Definition shelfmodel.cpp:837
void setRemotingEnabled(bool enabled)
Set whether to enable the remoting API server.
Definition shelfmodel.cpp:801
int density
Number of LEDs in each shelf compartment.
Definition shelfmodel.h:116
int rows
Number of boards in the shelf.
Definition shelfmodel.h:88
void setRows(int rows)
Set the number of boards in the shelf.
Definition shelfmodel.cpp:204
AdditionalRoles
Non-standard model data roles offered by this model.
Definition shelfmodel.h:260
@ AverageBrightness
Average brightness channel of the LEDs in a shelf compartment.
Definition shelfmodel.h:265
@ AverageGreen
Average green channel of the LEDs in a shelf compartment.
Definition shelfmodel.h:263
@ AverageBlue
Average blue channel of the LEDs in a shelf compartment.
Definition shelfmodel.h:264
@ AverageColor
Average color of the LEDs in a shelf compartment.
Definition shelfmodel.h:261
@ AverageRed
Average red channel of the LEDs in a shelf compartment.
Definition shelfmodel.h:262
void averageColorChanged(const QColor &color) const
The average color of the shelf has changed.
AbstractAnimation * animation
Animation to operate on ledStrip.
Definition shelfmodel.h:217
void setWallThickness(int thickness)
Set the number of LEDs behind each compartment-dividing wall.
Definition shelfmodel.cpp:308
LedStrip * ledStrip
LedStrip instance this model operates on.
Definition shelfmodel.h:61
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition shelfmodel.cpp:670
void remotingEnabledChanged() const
Whether to enable the remoting API server has changed.
void setAnimation(AbstractAnimation *animation)
Set animation operating on ledStrip.
Definition shelfmodel.cpp:562
void columnsChanged(int columns) const
The number of compartments in each shelf board has changed.
void enabledChanged(bool enabled) const
The shelf has turned on or off.
void classBegin() override
Implements the QQmlParserStatus interface.
Definition shelfmodel.cpp:832
bool animating
Toggle the animation.
Definition shelfmodel.h:229
void setAnimateAverageColorTransitions(bool animate)
Set whether to animate transitions between full-shelf color fills.
Definition shelfmodel.cpp:519
void animatingChanged(bool animating) const
Whether to run the animation has changed.
void animationChanged() const
The animation operating on ledStrip has changed.