22 #include "progressspinnerdelegate_p.h"
24 #include "entitytreemodel.h"
26 #include <QTimerEvent>
27 #include <QAbstractItemView>
31 DelegateAnimator::DelegateAnimator(QAbstractItemView *view)
36 m_pixmapSequence = KPixmapSequence(QLatin1String(
"process-working"), 22);
39 void DelegateAnimator::push(
const QModelIndex &index)
41 if (m_animations.isEmpty()) {
42 m_timerId = startTimer(200);
44 m_animations.insert(Animation(index));
47 void DelegateAnimator::pop(
const QModelIndex &index)
49 if (m_animations.remove(Animation(index))) {
50 if (m_animations.isEmpty() && m_timerId != -1) {
57 void DelegateAnimator::timerEvent(QTimerEvent *event)
59 if (!(event->timerId() == m_timerId && m_view)) {
60 return QObject::timerEvent(event);
64 foreach (
const Animation &animation, m_animations) {
74 animation.nextFrame();
75 const QRect rect = m_view->visualRect(animation.index);
79 if (!region.isEmpty()) {
80 m_view->viewport()->update(region);
84 QPixmap DelegateAnimator::sequenceFrame(
const QModelIndex &index)
86 foreach (
const Animation &animation, m_animations) {
87 if (animation.index == index) {
88 return m_pixmapSequence.frameAt(animation.frame);
94 ProgressSpinnerDelegate::ProgressSpinnerDelegate(DelegateAnimator *animator, QObject *parent)
95 : QStyledItemDelegate(parent)
96 , m_animator(animator)
101 void ProgressSpinnerDelegate::initStyleOption(QStyleOptionViewItem *option,
const QModelIndex &index)
const
103 QStyledItemDelegate::initStyleOption(option, index);
107 m_animator->pop(index);
111 m_animator->push(index);
113 if (QStyleOptionViewItemV4 *v4 = qstyleoption_cast<QStyleOptionViewItemV4 *>(option)) {
114 v4->icon = m_animator->sequenceFrame(index);
118 uint Akonadi::qHash(Akonadi::DelegateAnimator::Animation anim)
120 return qHash(anim.index);
@ FetchingState
There is a fetch of items in this collection in progress.
@ FetchStateRole
Returns the FetchState of a particular item.
FreeBusyManager::Singleton.