Home · All Namespaces · All Classes
Public Slots | Signals | Public Member Functions

PagedViewport Class Reference

PagedViewport creates a view that allows any widget to be panned a set of pages. More...

#include <pagedviewport.h>

Inheritance diagram for PagedViewport:
Inheritance graph
[legend]
Collaboration diagram for PagedViewport:
Collaboration graph
[legend]

List of all members.

Public Slots

void panToPage (uint page)
void setPage (uint page)
void focusFirstPage ()

Signals

void pageChanged (int newPage)
void pageCountChanged (int newPageCount)

Public Member Functions

 PagedViewport (QGraphicsItem *parent=0)
virtual ~PagedViewport ()
void setPanDirection (const Qt::Orientations &panDirection)
void updatePageCount (int pages)
 
int currentPage () const
int targetPage () const
float pageWidth () const
void setPageWrapMode (bool enable)

Detailed Description

PagedViewport creates a view that allows any widget to be panned a set of pages.

The PagedViewport extends the MPannableViewport functionality so that it pans the widget inside the viewport through pages. The page within this class refres to the visual appearance only.

The widget inside the MPannableViewport is not split into multiple component or widgets. The PagedViewport only modifies the movement of the MPannableViewport so that the widget being panned appears to consist of multiple pages.

Currently only horizontal paging is supported.

Definition at line 43 of file pagedviewport.h.


Constructor & Destructor Documentation

PagedViewport::PagedViewport ( QGraphicsItem *  parent = 0  ) 

Constructs a PagedViewport

Parameters:
parent The parent of this viewport

Definition at line 30 of file pagedviewport.cpp.

                                                  :
        MPannableViewport(parent),
        previousPage(0),
        layoutVisualizationWrapper(NULL)
{
    // The strategy will be deleted by the pannable viewport
    pagedPanning = new PagedPanning(this);
    setPhysics(pagedPanning);
    connect(pagedPanning, SIGNAL(pageChanged(int)), this, SIGNAL(pageChanged(int)));
    setPanDirection(Qt::Horizontal);

    PagePositionIndicator *positionIndicator = new PagePositionIndicator();
    connect(this, SIGNAL(pageCountChanged(int)), positionIndicator, SLOT(setPageCount(int)));
    connect(this, SIGNAL(pageChanged(int)), positionIndicator, SLOT(setFocusedPage(int)));
    setPositionIndicator(positionIndicator);

    connect(pagedPanning, SIGNAL(pageIsPanning(bool)), positionIndicator, SIGNAL(pageIsPanning(bool)));

    emit pageChanged(0);
}

PagedViewport::~PagedViewport (  )  [virtual]

Destroys this PagedViewport

Definition at line 51 of file pagedviewport.cpp.

{
}


Member Function Documentation

int PagedViewport::currentPage (  )  const

Returns the currently active page

Definition at line 84 of file pagedviewport.cpp.

{
    return pagedPanning->activePage();
}

Here is the call graph for this function:

void PagedViewport::focusFirstPage (  )  [slot]

Moves the viewport to the first page

Definition at line 71 of file pagedviewport.cpp.

{
    //TODO: add support for setting position to the right-most page
    // when using right-to-left layout
    pagedPanning->setPage(0);
}

Here is the call graph for this function:

void PagedViewport::pageChanged ( int  newPage  )  [signal]

This signal is sent when ever the page changes inside the viewport. The page change can occur programmatically or with an user interaction

Parameters:
newPage the page that the viewport is currently showing
void PagedViewport::pageCountChanged ( int  newPageCount  )  [signal]

This signal is sent when the page count is changed.

Parameters:
newPage the page new page count
float PagedViewport::pageWidth (  )  const

Returns the page width

Definition at line 94 of file pagedviewport.cpp.

{
    return pagedPanning->pageWidth();
}

Here is the call graph for this function:

void PagedViewport::panToPage ( uint  page  )  [slot]

Makes the viewport pan to a specific page. If the value exceeds the current amount of pages then the last page is shown.

Parameters:
page The page to pan to

Definition at line 60 of file pagedviewport.cpp.

{
    pagedPanning->panToPage(page);
}

Here is the call graph for this function:

void PagedViewport::setPage ( uint  page  )  [slot]

Moves the viewport to the specified page immediately without animation

Parameters:
page The page to set

Definition at line 65 of file pagedviewport.cpp.

{
    pagedPanning->setPage(page);
    previousPage = pagedPanning->activePage();
}

Here is the call graph for this function:

void PagedViewport::setPageWrapMode ( bool  enable  ) 

Enables or disables the page wrapping mode. When enabled, the pannable viewport wraps back to the first or the last page when panning over the opposite side.

Parameters:
enable enables or disables the mode

Definition at line 99 of file pagedviewport.cpp.

{
    pagedPanning->setPageWrapMode(enable);

    if (enable) {
        QGraphicsWidget *pannableWidget = widget();
        if (pannableWidget) {
            QGraphicsLinearLayout *pannableLayout = dynamic_cast<QGraphicsLinearLayout*>(pannableWidget->layout());
            if (pannableLayout) {
                layoutVisualizationWrapper = QSharedPointer<LayoutVisualizationWrapper>(new LayoutVisualizationWrapper(*pannableLayout));
                updateVisualizationWrapper();
                // Multiple signals are monitored to control the visualization wrapper
                // - panningStopped signal when rotation happens while panning
                connect(this, SIGNAL(panningStopped()), SLOT(updateVisualizationWrapper()));
                // - pageChanged signal when panning between pages without wrapping
                connect(this, SIGNAL(pageChanged(int)), SLOT(newPageSet(int)));
                // - pageWrapped signal when panning from first page to last or vice-versa via page wrapping
                connect(physics(), SIGNAL(pageWrapped()), SLOT(updateVisualizationWrapper()));
            }
        }
    } else {
        layoutVisualizationWrapper = QSharedPointer<LayoutVisualizationWrapper>(NULL);
        disconnect(SIGNAL(panningStopped()), this, SLOT(updateVisualizationWrapper()));
        disconnect(SIGNAL(pageChanged(int)), this, SLOT(newPageSet(int)));
        disconnect(physics(), SIGNAL(pageWrapped()), this, SLOT(updateVisualizationWrapper()));
    }
}

Here is the call graph for this function:

void PagedViewport::setPanDirection ( const Qt::Orientations &  panDirection  ) 

REIMPLEMENTATION Sets pan direction to horizontal regardles of user's wishes. Setting direction to vertical has undetermined effects since it's currently not supported

Definition at line 55 of file pagedviewport.cpp.

int PagedViewport::targetPage (  )  const

Gets the target page where the panning is going to if there is panning going on. If panning is not going on, then this returns the current page.

Definition at line 89 of file pagedviewport.cpp.

{
    return pagedPanning->targetPage();
}

Here is the call graph for this function:

void PagedViewport::updatePageCount ( int  pages  ) 

Set the number of pages.

Parameters:
pages The number of pages.

Definition at line 78 of file pagedviewport.cpp.

{
    pagedPanning->setPageCount(pages);
    emit pageCountChanged(pages);
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:

Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:20:42
Doxygen 1.7.1
MeeGo Touch