Finally, animation works.
This commit is contained in:
@@ -4,11 +4,14 @@
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class QPropertyAnimation;
|
||||
class QVariantAnimation;
|
||||
class QListView;
|
||||
|
||||
class BCItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal highlightOpacity READ highlightOpacity WRITE setHighlightOpacity)
|
||||
|
||||
public:
|
||||
|
||||
@@ -25,17 +28,45 @@ public:
|
||||
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex &index) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
qreal highlightOpacity() const
|
||||
{
|
||||
return _opacity;
|
||||
}
|
||||
|
||||
void setHighlightOpacity(qreal opacity)
|
||||
{
|
||||
_opacity = opacity;
|
||||
//qDebug() << " --- opa: " << opacity;
|
||||
emit viewUpdateNeeded();
|
||||
}
|
||||
|
||||
void clearAllHighlights();
|
||||
|
||||
public slots:
|
||||
|
||||
void onHighlightRow(int row);
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
void viewUpdateNeeded();
|
||||
|
||||
private:
|
||||
|
||||
void updateRow(int row);
|
||||
QString formatDisplayString(const QModelIndex &index) const;
|
||||
|
||||
int _highlightedRow{-1};
|
||||
QListView* _view{nullptr};
|
||||
qreal _opacity{1.0};
|
||||
QListView* _view{};
|
||||
QPropertyAnimation *_animation{};
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
QHash<int, qreal> m_rowOpacities;
|
||||
QHash<int, QVariantAnimation*> m_rowAnimations;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user