@ -28,6 +28,8 @@
# include "adaptors/UBSvgSubsetAdaptor.h"
# include "adaptors/UBSvgSubsetAdaptor.h"
# include "document/UBDocumentController.h"
# include "document/UBDocumentController.h"
# include "domain/UBGraphicsScene.h"
# include "domain/UBGraphicsScene.h"
# include "board/UBBoardPaletteManager.h"
# include "core/UBApplicationController.h"
# include "core/memcheck.h"
# include "core/memcheck.h"
@ -56,6 +58,7 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
connect ( UBApplication : : boardController , SIGNAL ( activeSceneChanged ( ) ) , this , SLOT ( addNewPage ( ) ) ) ;
connect ( UBApplication : : boardController , SIGNAL ( activeSceneChanged ( ) ) , this , SLOT ( addNewPage ( ) ) ) ;
connect ( UBApplication : : boardController , SIGNAL ( setDocOnPageNavigator ( UBDocumentProxy * ) ) , this , SLOT ( generateThumbnails ( ) ) ) ;
connect ( UBApplication : : boardController , SIGNAL ( setDocOnPageNavigator ( UBDocumentProxy * ) ) , this , SLOT ( generateThumbnails ( ) ) ) ;
connect ( mScene , SIGNAL ( selectionChanged ( ) ) , this , SLOT ( onSelectionChanged ( ) ) ) ;
connect ( mScene , SIGNAL ( selectionChanged ( ) ) , this , SLOT ( onSelectionChanged ( ) ) ) ;
connect ( UBApplication : : boardController , SIGNAL ( documentReorganized ( int ) ) , this , SLOT ( onMovedToIndex ( int ) ) ) ;
}
}
/**
/**
@ -107,13 +110,13 @@ void UBDocumentNavigator::generateThumbnails()
for ( int i = 0 ; i < thumbs . count ( ) ; i + + )
for ( int i = 0 ; i < thumbs . count ( ) ; i + + )
{
{
QPixmap pix = thumbs . at ( i ) ;
QPixmap pix = thumbs . at ( i ) ;
QGraphicsPixmapItem * pixmapItem = new UBSceneThumbnailPixmap ( pix , mCrntDoc , i ) ;
QGraphicsPixmapItem * pixmapItem = new UBSceneThumbnailNavig Pixmap ( pix , mCrntDoc , i ) ;
// Get the selected item
// Get the selected item
if ( UBApplication : : boardController - > activeSceneIndex ( ) = = i )
if ( UBApplication : : boardController - > activeSceneIndex ( ) = = i )
{
{
selection = pixmapItem ;
selection = pixmapItem ;
mCrntItem = dynamic_cast < UBSceneThumbnailPixmap * > ( pixmapItem ) ;
mCrntItem = dynamic_cast < UBSceneThumbnailNavig Pixmap * > ( pixmapItem ) ;
mCrntItem - > setSelected ( true ) ;
mCrntItem - > setSelected ( true ) ;
}
}
@ -145,7 +148,7 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage)
// Load it
// Load it
QList < QPixmap > thumbs = UBThumbnailAdaptor : : load ( mCrntDoc ) ;
QList < QPixmap > thumbs = UBThumbnailAdaptor : : load ( mCrntDoc ) ;
QPixmap pix = thumbs . at ( iPage ) ;
QPixmap pix = thumbs . at ( iPage ) ;
QGraphicsPixmapItem * pixmapItem = new UBSceneThumbnailPixmap ( pix , mCrntDoc , iPage ) ;
QGraphicsPixmapItem * pixmapItem = new UBSceneThumbnailNavig Pixmap ( pix , mCrntDoc , iPage ) ;
if ( pixmapItem )
if ( pixmapItem )
{
{
// Get the old thumbnail
// Get the old thumbnail
@ -370,7 +373,7 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
bNavig = true ;
bNavig = true ;
// First, select the clicked item
// First, select the clicked item
UBSceneThumbnailPixmap * pCrntItem = dynamic_cast < UBSceneThumbnailPixmap * > ( pClickedItem ) ;
UBSceneThumbnailNavig Pixmap * pCrntItem = dynamic_cast < UBSceneThumbnailNavig Pixmap * > ( pClickedItem ) ;
if ( NULL = = pCrntItem )
if ( NULL = = pCrntItem )
{
{
@ -378,7 +381,7 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
UBThumbnailTextItem * pTextItem = dynamic_cast < UBThumbnailTextItem * > ( pClickedItem ) ;
UBThumbnailTextItem * pTextItem = dynamic_cast < UBThumbnailTextItem * > ( pClickedItem ) ;
if ( NULL ! = pTextItem )
if ( NULL ! = pTextItem )
{
{
pCrntItem = dynamic_cast < UBSceneThumbnailPixmap * > ( mThumbnails . at ( mLabels . indexOf ( pTextItem ) ) ) ;
pCrntItem = dynamic_cast < UBSceneThumbnailNavig Pixmap * > ( mThumbnails . at ( mLabels . indexOf ( pTextItem ) ) ) ;
}
}
}
}
else
else
@ -387,12 +390,14 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event)
{
{
// Unselect the previous item
// Unselect the previous item
int iOldPage = mThumbnails . indexOf ( mCrntItem ) ;
int iOldPage = mThumbnails . indexOf ( mCrntItem ) ;
mCrntItem - > setSelected ( false ) ;
updateSpecificThumbnail ( iOldPage ) ;
updateSpecificThumbnail ( iOldPage ) ;
mCrntItem = pCrntItem ;
mCrntItem = pCrntItem ;
}
}
pCrntItem - > setSelected ( true ) ;
// HACK: for an unknown reason, the mousePressEvent of the item is not
// called when a click occurs on it. So I created this method in
// order to handle the click.
mCrntItem - > notifyClick ( mapToScene ( event - > pos ( ) ) ) ;
// Then display the related page
// Then display the related page
emit changeCurrentPage ( ) ;
emit changeCurrentPage ( ) ;
@ -435,3 +440,18 @@ void UBDocumentNavigator::onSelectionChanged()
// QList<QGraphicsItem*> qlItems = mScene->selectedItems();
// QList<QGraphicsItem*> qlItems = mScene->selectedItems();
// qDebug() << "The number of selected items is " << qlItems.count();
// qDebug() << "The number of selected items is " << qlItems.count();
}
}
/**
* \ brief Occurs when a page has been moved to another index in the document
* @ param index as the new index
*/
void UBDocumentNavigator : : onMovedToIndex ( int index )
{
UBSceneThumbnailNavigPixmap * pItem = dynamic_cast < UBSceneThumbnailNavigPixmap * > ( mThumbnails . at ( index ) ) ;
if ( NULL ! = pItem )
{
mCrntItem = pItem ;
mCrntItem - > setSelected ( true ) ;
centerOn ( mCrntItem ) ;
}
}