Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties

QxtFlowView Class Reference
[QxtGui]

An ItemView for Images with impressive Flow effects. More...

#include <qxtflowview.h>

Collaboration diagram for QxtFlowView:
Collaboration graph
[legend]

List of all members.

Public Types

enum  ReflectionEffect { NoReflection, PlainReflection, BlurredReflection }

Public Slots

void setCurrentIndex (QModelIndex index)
void showPrevious ()
void showNext ()
void showSlide (QModelIndex index)
void render ()
void triggerRender ()

Signals

void currentIndexChanged (QModelIndex index)

Public Member Functions

 QxtFlowView (QWidget *parent=0)
 ~QxtFlowView ()
void setModel (QAbstractItemModel *model)
QAbstractItemModel * model ()
QColor backgroundColor () const
void setBackgroundColor (const QColor &c)
QSize slideSize () const
void setSlideSize (QSize size)
QModelIndex currentIndex () const
QModelIndex rootIndex () const
 Returns the model index of the model's root item. The root item is the parent item to the view's toplevel items. The root can be invalid.
.
void setRootIndex (QModelIndex index)
 Sets the root item to the item at the given index.
.
ReflectionEffect reflectionEffect () const
void setReflectionEffect (ReflectionEffect effect)
int pictureRole ()
void setPictureRole (int)
int pictureColumn ()
void setPictureColumn (int)

Protected Member Functions

virtual void paintEvent (QPaintEvent *event)
virtual void keyPressEvent (QKeyEvent *event)
virtual void mousePressEvent (QMouseEvent *event)
virtual void mouseMoveEvent (QMouseEvent *event)
virtual void mouseReleaseEvent (QMouseEvent *event)
virtual void resizeEvent (QResizeEvent *event)
virtual void wheelEvent (QWheelEvent *event)

Properties

QColor backgroundColor
QSize slideSize
QModelIndex currentIndex
int pictureRole
int pictureColumn
QModelIndex rootIndex

Detailed Description

An ItemView for Images with impressive Flow effects.

an image show widget with animation effect like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form of slides, one main slide is shown at the center with few slides on the left and right sides of the center slide. When the next or previous slide is brought to the front, the whole slides flow to the right or the right with smooth animation effect; until the new slide is finally placed at the center.

This is a derived work of PictureFlow ( http://pictureflow.googlecode.com )

qxtflowview.png

QxtFlowView in action.

Definition at line 59 of file qxtflowview.h.


Member Enumeration Documentation

Enumerator:
NoReflection 
PlainReflection 
BlurredReflection 

Definition at line 78 of file qxtflowview.h.


Constructor & Destructor Documentation

QxtFlowView::QxtFlowView ( QWidget *  parent = 0 )

Creates a new PictureFlow widget.

Definition at line 82 of file qxtflowview.cpp.

References QxtFlowViewAnimator::animateTimer, QxtFlowViewPrivate::animator, QxtFlowViewAbstractRenderer::init(), QxtFlowViewPrivate::model, QxtFlowViewPrivate::piccolumn, QxtFlowViewPrivate::picrole, render(), QxtFlowViewPrivate::renderer, QxtFlowViewState::reposition(), QxtFlowViewState::reset(), QxtFlowViewAnimator::state, QxtFlowViewAbstractRenderer::state, QxtFlowViewPrivate::state, QxtFlowViewPrivate::textcolumn, QxtFlowViewPrivate::textrole, QxtFlowViewPrivate::triggerTimer, and QxtFlowViewAbstractRenderer::widget.

                                       : QWidget(parent)
{
    d = new QxtFlowViewPrivate;

    d->model = 0;
    d->picrole = Qt::DecorationRole;
    d->textrole = Qt::DisplayRole;
    d->piccolumn = 0;
    d->textcolumn = 0;



    d->state = new QxtFlowViewState;
    d->state->reset();
    d->state->reposition();

    d->renderer = new QxtFlowViewSoftwareRenderer;
    d->renderer->state = d->state;
    d->renderer->widget = this;
    d->renderer->init();

    d->animator = new QxtFlowViewAnimator;
    d->animator->state = d->state;
    QObject::connect(&d->animator->animateTimer, SIGNAL(timeout()), this, SLOT(updateAnimation()));

    QObject::connect(&d->triggerTimer, SIGNAL(timeout()), this, SLOT(render()));

    setAttribute(Qt::WA_StaticContents, true);
    setAttribute(Qt::WA_OpaquePaintEvent, true);
    setAttribute(Qt::WA_NoSystemBackground, true);
}
QxtFlowView::~QxtFlowView (  )

Destroys the widget.

Definition at line 114 of file qxtflowview.cpp.

References QxtFlowViewPrivate::animator, QxtFlowViewPrivate::renderer, and QxtFlowViewPrivate::state.

{
    delete d->renderer;
    delete d->animator;
    delete d->state;
    delete d;
}

Member Function Documentation

QColor QxtFlowView::backgroundColor (  ) const

Returns the background color.

QModelIndex QxtFlowView::currentIndex (  ) const

Returns the index of slide currently shown in the middle of the viewport.

Referenced by keyPressEvent().

void QxtFlowView::currentIndexChanged ( QModelIndex  index ) [signal]
void QxtFlowView::keyPressEvent ( QKeyEvent *  event ) [protected, virtual]

Definition at line 298 of file qxtflowview.cpp.

References currentIndex(), mitk::Key_Left, mitk::Key_Right, showNext(), showPrevious(), and QxtFlowViewPrivate::showSlide().

{
    if (event->key() == Qt::Key_Left)
    {
        if (event->modifiers() == Qt::ControlModifier)
            d->showSlide(currentIndex().row() - 10);
        else
            showPrevious();
        event->accept();
        return;
    }

    if (event->key() == Qt::Key_Right)
    {
        if (event->modifiers() == Qt::ControlModifier)
            d->showSlide(currentIndex().row() + 10);
        else
            showNext();
        event->accept();
        return;
    }

    event->ignore();
}
QAbstractItemModel * QxtFlowView::model (  )

Returns the model that this view is presenting.

Definition at line 127 of file qxtflowview.cpp.

References QxtFlowViewPrivate::model.

{
    return d->model;
}
void QxtFlowView::mouseMoveEvent ( QMouseEvent *  event ) [protected, virtual]

Definition at line 330 of file qxtflowview.cpp.

References QxtFlowViewPrivate::lastgrabpos, showNext(), showPrevious(), QxtFlowViewState::slideWidth, and QxtFlowViewPrivate::state.

{
    int i = (event->pos() - d->lastgrabpos).x() / (d->state->slideWidth / 4);
    if (i > 0)
    {
        showPrevious();
        d->lastgrabpos = event->pos();
    }
    if (i < 0)
    {
        showNext();
        d->lastgrabpos = event->pos();
    }

}
void QxtFlowView::mousePressEvent ( QMouseEvent *  event ) [protected, virtual]

Definition at line 323 of file qxtflowview.cpp.

References QxtFlowViewPrivate::lastgrabpos.

{
    d->lastgrabpos = event->pos();
}
void QxtFlowView::mouseReleaseEvent ( QMouseEvent *  event ) [protected, virtual]

Definition at line 346 of file qxtflowview.cpp.

{
    Q_UNUSED(event);

}
void QxtFlowView::paintEvent ( QPaintEvent *  event ) [protected, virtual]

Definition at line 353 of file qxtflowview.cpp.

References QxtFlowViewAbstractRenderer::paint(), and QxtFlowViewPrivate::renderer.

{
    Q_UNUSED(event);
    d->renderer->paint();
}
int QxtFlowView::pictureColumn (  )

Returns the column currently used for the image.

int QxtFlowView::pictureRole (  )

Returns the role currently used for the image.

QxtFlowView::ReflectionEffect QxtFlowView::reflectionEffect (  ) const

Returns the effect applied to the reflection.

Definition at line 157 of file qxtflowview.cpp.

References QxtFlowViewState::reflectionEffect, and QxtFlowViewPrivate::state.

{
    return d->state->reflectionEffect;
}
void QxtFlowView::render (  ) [slot]

Rerender the widget. Normally this function will be automatically invoked whenever necessary, e.g. during the transition animation.

Definition at line 245 of file qxtflowview.cpp.

References QxtFlowViewAbstractRenderer::dirty, and QxtFlowViewPrivate::renderer.

Referenced by QxtFlowView().

{
    d->renderer->dirty = true;
    update();
}
void QxtFlowView::resizeEvent ( QResizeEvent *  event ) [protected, virtual]

Definition at line 359 of file qxtflowview.cpp.

References triggerRender().

QModelIndex QxtFlowView::rootIndex (  ) const

Returns the model index of the model's root item. The root item is the parent item to the view's toplevel items. The root can be invalid.
.

See also:
setRootIndex();
void QxtFlowView::setBackgroundColor ( const QColor &  c )

Sets the background color. By default it is black.

Definition at line 138 of file qxtflowview.cpp.

References QxtFlowViewState::backgroundColor, QxtFlowViewPrivate::state, and triggerRender().

{
    d->state->backgroundColor = c.rgb();
    triggerRender();
}
void QxtFlowView::setCurrentIndex ( QModelIndex  index ) [slot]

Sets slide to be shown in the middle of the viewport. No animation effect will be produced, unlike using showSlide.

Definition at line 239 of file qxtflowview.cpp.

References QxtFlowViewPrivate::setCurrentIndex().

{
    d->setCurrentIndex(index);
}
void QxtFlowView::setModel ( QAbstractItemModel *  model )

Sets the model for the view to present.
Note: The view does not take ownership of the model unless it is the model's parent object because it may be shared between many different views.

Definition at line 122 of file qxtflowview.cpp.

References QxtFlowViewPrivate::setModel().

{
    d->setModel(model);
}
void QxtFlowView::setPictureColumn ( int  a )

Sets the column to use for the image. the default is 0

Definition at line 189 of file qxtflowview.cpp.

References QxtFlowViewPrivate::piccolumn, and QxtFlowViewPrivate::reset().

{
    d->piccolumn = a;
    d->reset();
}
void QxtFlowView::setPictureRole ( int  a )

Sets the role to use for the image. the default is Qt::DecorationRole

Definition at line 174 of file qxtflowview.cpp.

References QxtFlowViewPrivate::picrole, and QxtFlowViewPrivate::reset().

{
    d->picrole = a;
    d->reset();
}
void QxtFlowView::setReflectionEffect ( ReflectionEffect  effect )

Sets the effect applied to the reflection. The default is PlainReflection.

Definition at line 162 of file qxtflowview.cpp.

References QxtFlowViewState::reflectionEffect, QxtFlowViewPrivate::reset(), and QxtFlowViewPrivate::state.

{
    d->state->reflectionEffect = effect;
    d->reset();
}
void QxtFlowView::setRootIndex ( QModelIndex  index )

Sets the root item to the item at the given index.
.

See also:
rootIndex();

Definition at line 225 of file qxtflowview.cpp.

References QxtFlowViewPrivate::rootindex.

{
    d->rootindex = index;
}
void QxtFlowView::setSlideSize ( QSize  size )

Sets the dimension of each slide (in pixels).

Definition at line 149 of file qxtflowview.cpp.

References QxtFlowViewState::reposition(), QxtFlowViewState::slideHeight, QxtFlowViewState::slideWidth, QxtFlowViewPrivate::state, and triggerRender().

{
    d->state->slideWidth = size.width();
    d->state->slideHeight = size.height();
    d->state->reposition();
    triggerRender();
}
void QxtFlowView::showNext (  ) [slot]

Shows next slide using animation effect.

Definition at line 273 of file qxtflowview.cpp.

References QxtFlowViewPrivate::animator, QxtFlowViewState::centerIndex, QxtFlowViewState::slideImages, QxtFlowViewAnimator::start(), QxtFlowViewPrivate::state, QxtFlowViewAnimator::step, and QxtFlowViewAnimator::target.

Referenced by keyPressEvent(), mouseMoveEvent(), and wheelEvent().

{
    int step = d->animator->step;
    int center = d->state->centerIndex;

    if (step < 0)
        d->animator->start(center);

    if (step == 0)
        if (center < d->state->slideImages.count() - 1)
            d->animator->start(center + 1);

    if (step > 0)
        d->animator->target = qMin(center + 2, d->state->slideImages.count() - 1);
}
void QxtFlowView::showPrevious (  ) [slot]

Shows previous slide using animation effect.

Definition at line 257 of file qxtflowview.cpp.

References QxtFlowViewPrivate::animator, QxtFlowViewState::centerIndex, QxtFlowViewAnimator::start(), QxtFlowViewPrivate::state, QxtFlowViewAnimator::step, and QxtFlowViewAnimator::target.

Referenced by keyPressEvent(), mouseMoveEvent(), and wheelEvent().

{
    int step = d->animator->step;
    int center = d->state->centerIndex;

    if (step > 0)
        d->animator->start(center);

    if (step == 0)
        if (center > 0)
            d->animator->start(center - 1);

    if (step < 0)
        d->animator->target = qMax(0, center - 2);
}
void QxtFlowView::showSlide ( QModelIndex  index ) [slot]

Go to specified slide using animation effect.

Definition at line 289 of file qxtflowview.cpp.

References QxtFlowViewPrivate::modelmap, and QxtFlowViewPrivate::showSlide().

{
    int r = d->modelmap.indexOf(index);
    if (r < 0)
        return;

    d->showSlide(r);
}
QSize QxtFlowView::slideSize (  ) const

Returns the dimension of each slide (in pixels).

void QxtFlowView::triggerRender (  ) [slot]

Schedules a rendering update. Unlike render(), this function does not cause immediate rendering.

Definition at line 251 of file qxtflowview.cpp.

References QxtFlowViewPrivate::triggerRender().

Referenced by resizeEvent(), setBackgroundColor(), and setSlideSize().

{
    d->triggerRender();
}
void QxtFlowView::wheelEvent ( QWheelEvent *  event ) [protected, virtual]

Definition at line 367 of file qxtflowview.cpp.

References showNext(), and showPrevious().

{

    if (event->orientation() == Qt::Horizontal)
    {
        event->ignore();
    }
    else
    {
        int numSteps = -((event->delta() / 8) / 15);



        if (numSteps > 0)
        {
            for (int i = 0;i < numSteps;i++)
            {
                showNext();
            }
        }
        else
        {
            for (int i = numSteps;i < 0;i++)
            {
                showPrevious();
            }
        }
        event->accept();
    }


}

Property Documentation

QColor QxtFlowView::backgroundColor [read, write]

Definition at line 63 of file qxtflowview.h.

QModelIndex QxtFlowView::currentIndex [read, write]

Definition at line 65 of file qxtflowview.h.

int QxtFlowView::pictureColumn [read, write]

Definition at line 67 of file qxtflowview.h.

int QxtFlowView::pictureRole [read, write]

Definition at line 66 of file qxtflowview.h.

QModelIndex QxtFlowView::rootIndex [read, write]

Definition at line 68 of file qxtflowview.h.

QSize QxtFlowView::slideSize [read, write]

Definition at line 64 of file qxtflowview.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines