pageNumberEdit::pageNumberEdit( QWidget *main ): QToolBar( main ), actionWidget( NULL ) { /* Create the Next, Prev actions and the line edit * and add them to the toolbar */ QAction *prevAct = addAction( QIcon::fromTheme("go-previous"), tr("&Previous Page"), this, SLOT( wantPrev() ) ); pageEdit = new QLineEdit( this ); addWidget( pageEdit ); QAction *nextAct = addAction( QIcon::fromTheme("go-next"), tr("&Next Page"), this, SLOT( wantNext() ) ); nextAct->setShortcut( QString( "Ctrl+N" ) ); prevAct->setShortcut( QString( "Ctrl+P" ) ); /* Line Edit setup */ pageEdit->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); lastValidPageNumber = 0; setMaxPageNum( 0 ); pageEdit->setCursorPosition(0); connect( pageEdit, SIGNAL( textEdited(QString) ), this, SLOT( pageNumberChanged() ) ); connect( pageEdit, SIGNAL( cursorPositionChanged(int,int) ), this, SLOT( cursorChanged(int,int) ) ); connect( pageEdit, SIGNAL( editingFinished() ), this, SLOT( wantGoTo() ) ); /* If mainWin is a widget, add the actions there, so that they are * global and shortcuts work globaly */ if ( actionWidget = main ) { actionWidget->addAction( nextAct ); actionWidget->addAction( prevAct ); } setMaximumSize(200,300); }
void PageItem::setPageNumber(int number) { if ((m_page && m_viewPort.pageNumber == number) || !m_documentItem || !m_documentItem.data()->isOpened() || number < 0 || (uint)number >= m_documentItem.data()->document()->pages()) { return; } m_viewPort.pageNumber = number; m_page = m_documentItem.data()->document()->page(number); emit pageNumberChanged(); emit implicitWidthChanged(); emit implicitHeightChanged(); checkBookmarksChanged(); m_redrawTimer->start(); }