Some more changes according to the review.

This commit is contained in:
Michel Ludwig 2011-10-31 21:41:50 +00:00
parent 31828b4850
commit a823df5c8f
5 changed files with 36 additions and 19 deletions

View file

@ -730,6 +730,16 @@ class OKULAR_EXPORT Document : public QObject
*/ */
void formFieldChanged( Okular::FormField *formField ); void formFieldChanged( Okular::FormField *formField );
/**
* This signal is emitted whenever a source reference with the given parameters has been
* activated.
*
* \param handled should be set to 'true' if a slot handles this source reference; the
* default action to launch the configured editor will then not be performed
* by the document
*
* @since 0.14 (KDE 4.8)
*/
void sourceReferenceActivated(const QString& absFileName, int line, int col, bool *handled); void sourceReferenceActivated(const QString& absFileName, int line, int col, bool *handled);
private: private:

View file

@ -78,6 +78,11 @@ enum ScriptType
JavaScript = 0 ///< JavaScript code JavaScript = 0 ///< JavaScript code
}; };
/**
* Describes the possible embedding modes of the part
*
* @since 0.14 (KDE 4.8)
*/
enum EmbedMode enum EmbedMode
{ {
UnknownEmbedMode, UnknownEmbedMode,

View file

@ -828,37 +828,39 @@ KUrl Part::realUrl() const
void Part::showSourceLocation(const QString& fileName, int line, int column) void Part::showSourceLocation(const QString& fileName, int line, int column)
{ {
QString u = "src:" + QString::number(line) + ' ' + fileName; const QString u = QString( "src:%1 %2" ).arg( line ).arg( fileName );
GotoAction action(QString(), u); GotoAction action( QString(), u );
m_document->processAction(&action); m_document->processAction( &action );
} }
void Part::setWatchFileModeEnabled(bool b) void Part::setWatchFileModeEnabled(bool enabled)
{ {
if (b && m_watcher->isStopped()) { if ( enabled && m_watcher->isStopped() )
{
m_watcher->startScan(); m_watcher->startScan();
} }
else if(!b && !m_watcher->isStopped() ) else if( !enabled && !m_watcher->isStopped() )
{ {
m_dirtyHandler->stop(); m_dirtyHandler->stop();
m_watcher->stopScan(); m_watcher->stopScan();
} }
} }
void Part::setShowSourceLocationsGraphically(bool b) void Part::setShowSourceLocationsGraphically(bool show)
{ {
if( b == Okular::Settings::showSourceLocationsGraphically() ) if( show == Okular::Settings::showSourceLocationsGraphically() )
{ {
return; return;
} }
Okular::Settings::setShowSourceLocationsGraphically(b); Okular::Settings::setShowSourceLocationsGraphically( show );
m_pageView->repaint(); m_pageView->update();
} }
void Part::slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled) void Part::slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled)
{ {
emit(openSourceReference(absFileName, line, col)); emit openSourceReference( absFileName, line, col );
if ( m_embedMode == Okular::ViewerWidgetMode ) { if ( m_embedMode == Okular::ViewerWidgetMode )
{
*handled = true; *handled = true;
} }
} }
@ -1544,7 +1546,7 @@ void Part::updateViewActions()
menu = factory()->container("view_orientation", this); menu = factory()->container("view_orientation", this);
if (menu) menu->setEnabled( opened ); if (menu) menu->setEnabled( opened );
} }
emit(viewerMenuStateChange( opened )); emit viewerMenuStateChange( opened );
updateBookmarksActions(); updateBookmarksActions();
} }

4
part.h
View file

@ -106,8 +106,8 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
KUrl realUrl() const; KUrl realUrl() const;
void showSourceLocation(const QString& fileName, int line, int column); void showSourceLocation(const QString& fileName, int line, int column);
void setWatchFileModeEnabled(bool b); void setWatchFileModeEnabled(bool enable);
void setShowSourceLocationsGraphically(bool b); void setShowSourceLocationsGraphically(bool show);
public slots: // dbus public slots: // dbus
Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page); Q_SCRIPTABLE Q_NOREPLY void goToPage(uint page);

View file

@ -533,7 +533,6 @@ void PageView::setupActions( KActionCollection * ac )
d->aMouseTextSelect->setIconText( i18nc( "Text Selection Tool", "Text Selection" ) ); d->aMouseTextSelect->setIconText( i18nc( "Text Selection Tool", "Text Selection" ) );
d->aMouseTextSelect->setCheckable( true ); d->aMouseTextSelect->setCheckable( true );
d->aMouseTextSelect->setShortcut( Qt::CTRL + Qt::Key_4 ); d->aMouseTextSelect->setShortcut( Qt::CTRL + Qt::Key_4 );
Q_ASSERT( d->mouseModeActionGroup );
d->aMouseTextSelect->setActionGroup( d->mouseModeActionGroup ); d->aMouseTextSelect->setActionGroup( d->mouseModeActionGroup );
d->aMouseTableSelect = new KAction(KIcon( "select-table" ), i18n("T&able Selection Tool"), this); d->aMouseTableSelect = new KAction(KIcon( "select-table" ), i18n("T&able Selection Tool"), this);
@ -1059,8 +1058,9 @@ void PageView::notifyViewportChanged( bool smoothMove )
if ( d->zoomMode != ZoomFixed ) if ( d->zoomMode != ZoomFixed )
updateZoomText(); updateZoomText();
if(viewport()) { if( viewport() )
viewport()->repaint(); {
viewport()->update();
} }
// since the page has moved below cursor, update it // since the page has moved below cursor, update it
@ -3276,7 +3276,7 @@ void PageView::updateZoomText()
else if ( d->zoomMode == ZoomFitText ) else if ( d->zoomMode == ZoomFitText )
selIdx = 2; selIdx = 2;
d->aZoom->setCurrentItem( selIdx ); d->aZoom->setCurrentItem( selIdx );
d->aZoom->setEnabled(d->items.size() > 0); d->aZoom->setEnabled( d->items.size() > 0 );
d->aZoom->selectableActionGroup()->setEnabled( d->items.size() > 0 ); d->aZoom->selectableActionGroup()->setEnabled( d->items.size() > 0 );
} }