void
HoverIndex::timerEvent(QTimerEvent * event)
{
    if (event->timerId() != timer.timerId() || items.isEmpty())
        return;

    Items::iterator it;
    IndexInfo::Fades::iterator step;
    it = items.begin();
    QWidget *w;
    while (it != items.end())
    {
        if (it.key().isNull())
        {
            it = items.erase(it);
            continue;
        }
        w = const_cast<QWidget*>(it.key().data());
        IndexInfo &info = it.value();
        if (info.fades[In].isEmpty() && info.fades[Out].isEmpty())
        {
            ++it; continue;
        }

        step = info.fades[In].begin();
        while (step != info.fades[In].end())
        {
            step.value() += 2;
            if ((uint)step.value() > (maxSteps-2))
                step = info.fades[In].erase(step);
            else
                ++step;
        }

        step = info.fades[Out].begin();
        while (step != info.fades[Out].end())
        {
            step.value() -= 2;
            if (step.value() < 1)
                step = info.fades[Out].erase(step);
            else
                ++step;
        }

        w->update();

        if (info.index == 0L && // nothing actually hovered
            info.fades[In].isEmpty() && // no fade ins
            info.fades[Out].isEmpty()) // no fade outs
            it = items.erase(it); // so remove this item
        else
            ++it;
    }

    if (items.isEmpty())
        timer.stop();
}
void
HoverComplex::timerEvent(QTimerEvent * event)
{
    if (event->timerId() != timer.timerId() || items.isEmpty())
        return;

    bool update;
    Items::iterator it = items.begin();
    ComplexInfo *info;
    while (it != items.end())
    {
        if (!it.key())
        {
            it = items.erase(it);
            continue;
        }
        info = &it.value();
        update = false;
        for (QStyle::SubControl control = (QStyle::SubControl)0x01;
            control <= (QStyle::SubControl)0x80;
            control = (QStyle::SubControl)(control<<1))
            {
                if (info->fades[In] & control)
                {
                    update = true;
                    info->steps[control] += 2;
                    if (info->steps.value(control) > 4)
                        info->fades[In] &= ~control;
                }
                else if (info->fades[Out] & control)
                {
                    update = true;
                    --info->steps[control];
                    if (info->steps.value(control) < 1)
                        info->fades[Out] &= ~control;
                }
            }
        if (update)
            it.key()->update();
        if (info->active == QStyle::SC_None && // needed to detect changes!
                                                info->fades[Out] == QStyle::SC_None &&
                                                info->fades[In] == QStyle::SC_None)
            it = items.erase(it);
        else
            ++it;
    }

    if (items.isEmpty())
        timer.stop();
}
Пример #3
0
void
Hover::timerEvent(QTimerEvent * event)
{
    if (event->timerId() != timer.timerId() || noAnimations())
        return;

    Items::iterator it = items.begin();
    int *step = 0;
    QWidget *widget = 0;
    while (it != items.end())
    {
        widget = it.key();
        if (!widget)
        {
            it = items.erase(it);
            continue;
        }
        step = &it.value()._step;
        if (it.value().backwards)
        {   // fade OUT
            --(*step);
            widget->update();
            if (*step < 1)
            {
#if WOBBLE_HOVER
                if (widget->testAttribute(Qt::WA_UnderMouse))
                    it.value().backwards = false;
                else
#endif
                    it = items.erase(it);
            }
            else
                ++it;
        }
        else
        {   // fade IN
            *step += HOVER_IN_STEP;
            widget->update();
            if ((uint)(*step) > maxSteps-2)
            {
#if WOBBLE_HOVER
                if (widget->testAttribute(Qt::WA_UnderMouse))
                    it.value().backwards = true;
                else
#endif
                    it = items.erase(it);
            }
            else
                ++it;
        }
    }
    if (noAnimations())
        timer.stop();
}
void
HoverIndex::release(QObject *o)
{
    QWidget *w = qobject_cast<QWidget*>(o);
    if (!w)
        return;
    Items::iterator it = items.begin(), end = items.end();
    while (it != end) {
        if (it.key().isNull()) {
            it = items.erase(it);
            continue;
        }
        if (it.key().data() == w) {
            items.erase(it);
            break;
        }
        ++it;
    }
    if (items.isEmpty())
        timer.stop();
}
Пример #5
0
 PyObject* keys()
 {
     PyObject* pylist = PyList_New( m_items->size() );
     if( !pylist )
         return 0;
     Py_ssize_t listidx = 0;
     Items::iterator it;
     Items::iterator end_it = m_items->end();
     for( it = m_items->begin(); it != end_it; ++it )
     {
         PyList_SET_ITEM( pylist, listidx, newref( it->key() ) );
         ++listidx;
     }
     return pylist;
 }
Пример #6
0
 PyObject* items()
 {
     PyObject* pylist = PyList_New( m_items->size() );
     if( !pylist )
         return 0;
     Py_ssize_t listidx = 0;
     Items::iterator it;
     Items::iterator end_it = m_items->end();
     for( it = m_items->begin(); it != end_it; ++it )
     {
         PyObject* pytuple = PyTuple_New( 2 );
         if( !pytuple )
             return 0;
         PyTuple_SET_ITEM( pytuple, 0, newref( it->key() ) );
         PyTuple_SET_ITEM( pytuple, 1, newref( it->value() ) );
         PyList_SET_ITEM( pylist, listidx, pytuple );
         ++listidx;
     }
     return pylist;
 }
Пример #7
0
void
Basic::timerEvent(QTimerEvent * event)
{
    if (event->timerId() != timer.timerId() || noAnimations())
        return;
    //Update the registered progressbars.
    QWidget *w;
    Items::iterator it = items.begin();
    while (it != items.end())
    {
        w = it.key();
        if (!w)
        {
            it = items.erase(it);
            continue;
        }
        if (w->paintingActive() || !w->isVisible())
            continue;
        ++it.value();
        w->repaint();
        ++it;
    }
}
void
Progress::timerEvent(QTimerEvent * event)
{
    if (event->timerId() != timer.timerId() || noAnimations())
        return;

    //Update the registered progressbars.
    Items::iterator iter;
    QProgressBar *pb;
    bool mkProper = false;
    animationUpdate = true;
    for (iter = items.begin(); iter != items.end(); iter++)
    {
        QWidget *w = const_cast<QWidget*>(iter.key().data());
        if (!w) // not a progressbar - shouldn't be in items, btw...
            { mkProper = true; continue; }

        pb = qobject_cast<QProgressBar*>(w);
        if (!pb)
            continue; // not a progressbar - shouldn't be in items, btw...

        if (pb->maximum() != 0 || pb->minimum() != 0 || pb->paintingActive() || !pb->isVisible())
        {
            pb->setAttribute(Qt::WA_OpaquePaintEvent, false);
            continue; // no paint necessary
        }

        pb->setAttribute(Qt::WA_OpaquePaintEvent);

        ++iter.value();

        // dump pb geometry
        int x,y,l,t, *step = &iter.value()._step;
        if ( pb->orientation() == Qt::Vertical ) // swapped values
            pb->rect().getRect(&y,&x,&t,&l);
        else
            pb->rect().getRect(&x,&y,&l,&t);

        if (*step > l/_speed)
            *step = l/36-(int)(l/_speed);
        else if (*step == -1)
            *step = l/36-1;

        int s = qMin(qMax(l / 10, 16), qMin(t, 20));
        int ss = (3*s)/4;
        int n = l/s;
        if ( pb->orientation() == Qt::Vertical)
            { x = pb->rect().bottom(); x -= (l - n*s)/2 + ss; /*s = -s;*/ }
        else
            { x += (l - n*s)/2; /*s = qAbs(s);*/ }

        x += qMax((int)(_speed*qAbs(*step)*n*s/l) - s, 0);
        if ( pb->orientation() == Qt::Vertical )
            pb->repaint(y,x-s,s,3*s);
        else
            pb->repaint(x-s,y,3*s,s);
    }
    animationUpdate = false;
    if (mkProper)
        _release(NULL);
}
Пример #9
0
void
HoverIndex::timerEvent(QTimerEvent * event)
{
    if (event->timerId() != timer.timerId() || items.isEmpty())
        return;

    Items::iterator it;
    IndexInfo::Fades::iterator step;
    it = items.begin();
    QWidget *w;
    while (it != items.end())
    {
        if (!it.key())
        {
            it = items.erase(it);
            continue;
        }
#if QT_VERSION >= 0x040400
        // below does work in general, but is... ugly?!
        // another way would be to map to a const widget first or perform a static_cast - ughh
        w = const_cast<QWidget*>(it.key().data());
#else
        w = const_cast<QWidget*>(&(*it.key()));
#endif
        IndexInfo &info = it.value();
        if (info.fades[In].isEmpty() && info.fades[Out].isEmpty())
        {
            ++it; continue;
        }

        step = info.fades[In].begin();
        while (step != info.fades[In].end())
        {
            step.value() += 2;
            if ((uint)step.value() > (maxSteps-2))
                step = info.fades[In].erase(step);
            else
                ++step;
        }

        step = info.fades[Out].begin();
        while (step != info.fades[Out].end())
        {
            step.value() -= 2;
            if (step.value() < 1)
                step = info.fades[Out].erase(step);
            else
                ++step;
        }

        w->update();

        if (info.index == 0L && // nothing actually hovered
            info.fades[In].isEmpty() && // no fade ins
            info.fades[Out].isEmpty()) // no fade outs
            it = items.erase(it); // so remove this item
        else
            ++it;
    }

    if (items.isEmpty())
        timer.stop();
}