Commit 945c1e1b authored by Ahmad Samir's avatar Ahmad Samir Committed by Albert Astals Cid
Browse files

[ui/*] Replace foreach (deprecated) with range-for

The code compiles, tests pass (except for two tests but they fail
on master too). Okular loads and seems to work.
parent ccf3a384
Pipeline #11629 passed with stage
in 11 minutes and 4 seconds
......@@ -46,7 +46,7 @@ static QLinkedList< Okular::Annotation* > filterOutWidgetAnnotations( const QLin
{
QLinkedList< Okular::Annotation* > result;
foreach ( Okular::Annotation *annotation, annotations )
for ( Okular::Annotation *annotation : annotations )
{
if ( annotation->subType() == Okular::Annotation::AWidget )
continue;
......@@ -119,8 +119,9 @@ static void updateAnnotationPointer( AnnItem *item, const QVector< Okular::Page
qWarning() << "Lost annotation on document save, something went wrong";
}
foreach ( AnnItem *child, item->children )
for ( AnnItem *child : qAsConst(item->children) ) {
updateAnnotationPointer( child, pages );
}
}
void AnnotationModelPrivate::notifySetup( const QVector< Okular::Page * > &pages, int setupFlags )
......
......@@ -96,7 +96,7 @@ void AnnotationPopup::exec( const QPoint &point )
action->setEnabled( mDocument->isAllowed( Okular::AllowNotes ) );
action->setProperty( actionTypeId, deleteAllId );
foreach ( const AnnotPagePair& pair, mAnnotations )
for ( const AnnotPagePair &pair : qAsConst(mAnnotations) )
{
if ( !mDocument->canRemovePageAnnotation( pair.annotation ) )
action->setEnabled( false );
......@@ -123,7 +123,7 @@ void AnnotationPopup::exec( const QPoint &point )
}
else
{
foreach ( const AnnotPagePair& pair, mAnnotations )
for ( const AnnotPagePair &pair : qAsConst(mAnnotations) )
{
menu.addAction( new OKMenuTitle( &menu, GuiUtils::captionForAnnotation( pair.annotation ) ) );
......@@ -170,7 +170,7 @@ void AnnotationPopup::exec( const QPoint &point )
if ( pair.pageNumber != -1 )
mDocument->removePageAnnotation( pair.pageNumber, pair.annotation );
} else if( actionType == deleteAllId ) {
Q_FOREACH ( const AnnotPagePair& pair, mAnnotations )
for ( const AnnotPagePair &pair : qAsConst(mAnnotations) )
{
if ( pair.pageNumber != -1 )
mDocument->removePageAnnotation( pair.pageNumber, pair.annotation );
......
......@@ -320,7 +320,7 @@ QList<QTreeWidgetItem*> createItems( const QUrl& baseurl, const KBookmark::List&
{
Q_UNUSED(baseurl)
QList<QTreeWidgetItem*> ret;
foreach ( const KBookmark& bm, bmlist )
for ( const KBookmark &bm : bmlist )
{
// qCDebug(OkularUiDebug).nospace() << "checking '" << tmp << "'";
// qCDebug(OkularUiDebug).nospace() << " vs '" << baseurl << "'";
......@@ -340,12 +340,12 @@ void BookmarkList::rebuildTree( bool filter )
m_currentDocumentItem = nullptr;
m_tree->clear();
QList<QUrl> urls = m_document->bookmarkManager()->files();
const QList<QUrl> urls = m_document->bookmarkManager()->files();
if ( filter )
{
if ( m_document->isOpened() )
{
foreach ( const QUrl& url, urls )
for ( const QUrl &url : urls )
{
if ( url == m_document->currentDocument() )
{
......@@ -359,7 +359,7 @@ void BookmarkList::rebuildTree( bool filter )
else
{
QTreeWidgetItem * currenturlitem = nullptr;
foreach ( const QUrl& url, urls )
for ( const QUrl &url : urls )
{
QList<QTreeWidgetItem*> subitems = createItems( url, m_document->bookmarkManager()->bookmarks( url ) );
if ( !subitems.isEmpty() )
......
......@@ -84,7 +84,7 @@ void DrawingToolActions::actionTriggered()
if ( action ) {
if ( action->isChecked() ) {
Q_FOREACH ( QAction *btn, m_actions )
for ( QAction *btn : qAsConst(m_actions) )
{
if ( action != btn ) {
btn->setChecked( false );
......@@ -104,7 +104,7 @@ void DrawingToolActions::loadTools()
QDomDocument doc;
QDomElement drawingDefinition = doc.createElement( QStringLiteral("drawingTools") );
foreach ( const QString &drawingXml, drawingTools )
for ( const QString &drawingXml : drawingTools )
{
QDomDocument entryParser;
if ( entryParser.setContent( drawingXml ) )
......
......@@ -78,7 +78,8 @@ EmbeddedFilesDialog::EmbeddedFilesDialog(QWidget *parent, const Okular::Document
m_tw->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_tw->setContextMenuPolicy(Qt::CustomContextMenu);
foreach(Okular::EmbeddedFile* ef, *document->embeddedFiles())
// embeddedFiles() returns a const QList
for (Okular::EmbeddedFile *ef : *document->embeddedFiles())
{
QTreeWidgetItem *twi = new QTreeWidgetItem();
twi->setText(0, ef->name());
......@@ -119,8 +120,8 @@ void EmbeddedFilesDialog::updateSaveButton()
void EmbeddedFilesDialog::saveFile()
{
QList<QTreeWidgetItem *> selected = m_tw->selectedItems();
foreach(QTreeWidgetItem *twi, selected)
const QList<QTreeWidgetItem *> selected = m_tw->selectedItems();
for (const QTreeWidgetItem *twi : selected)
{
Okular::EmbeddedFile* ef = qvariant_cast< Okular::EmbeddedFile* >( twi->data( 0, EmbeddedFileRole ) );
saveFile(ef);
......@@ -129,8 +130,8 @@ void EmbeddedFilesDialog::saveFile()
void EmbeddedFilesDialog::viewFile()
{
QList<QTreeWidgetItem *> selected = m_tw->selectedItems();
foreach(QTreeWidgetItem *twi, selected)
const QList<QTreeWidgetItem *> selected = m_tw->selectedItems();
for (QTreeWidgetItem *twi : selected)
{
Okular::EmbeddedFile* ef = qvariant_cast< Okular::EmbeddedFile* >( twi->data( 0, EmbeddedFileRole ) );
viewFile( ef );
......
......@@ -213,7 +213,7 @@ void FormWidgetsController::slotButtonClicked( QAbstractButton *button )
QList< bool > prevChecked;
QList< Okular::FormFieldButton*> formButtons;
foreach ( QAbstractButton* button, buttons )
for ( QAbstractButton* button : buttons )
{
checked.append( button->isChecked() );
Okular::FormFieldButton *formButton = static_cast<Okular::FormFieldButton *>( dynamic_cast<FormWidgetIface*>(button)->formField() );
......@@ -233,7 +233,7 @@ void FormWidgetsController::slotButtonClicked( QAbstractButton *button )
void FormWidgetsController::slotFormButtonsChangedByUndoRedo( int pageNumber, const QList< Okular::FormFieldButton* > & formButtons)
{
foreach ( Okular::FormFieldButton* formButton, formButtons )
for ( const Okular::FormFieldButton* formButton : formButtons )
{
int id = formButton->id();
QAbstractButton* button = m_buttons[id];
......@@ -949,10 +949,10 @@ ListEdit::ListEdit( Okular::FormFieldChoice * choice, QWidget * parent )
addItems( choice->choices() );
setSelectionMode( choice->multiSelect() ? QAbstractItemView::ExtendedSelection : QAbstractItemView::SingleSelection );
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
QList< int > selectedItems = choice->currentChoices();
const QList< int > selectedItems = choice->currentChoices();
if ( choice->multiSelect() )
{
foreach ( int index, selectedItems )
for ( const int index : selectedItems )
if ( index >= 0 && index < count() )
item( index )->setSelected( true );
}
......@@ -980,11 +980,11 @@ void ListEdit::setFormWidgetsController( FormWidgetsController* controller )
void ListEdit::slotSelectionChanged()
{
QList< QListWidgetItem * > selection = selectedItems();
const QList< QListWidgetItem * > selection = selectedItems();
QList< int > rows;
foreach( const QListWidgetItem * item, selection )
for ( const QListWidgetItem * item : selection ) {
rows.append( row( item ) );
}
Okular::FormFieldChoice *form = static_cast<Okular::FormFieldChoice *>(m_ff);
if ( rows != form->currentChoices() ) {
m_controller->formListChangedByWidget( pageItem()->pageNumber(),
......
......@@ -35,7 +35,7 @@ LatexRenderer::LatexRenderer()
LatexRenderer::~LatexRenderer()
{
foreach(const QString &file, m_fileList)
for (const QString &file : qAsConst(m_fileList))
{
QFile::remove(file);
}
......
......@@ -80,7 +80,7 @@ void MiniBarLogic::notifySetup( const QVector< Okular::Page * > & pageVector, in
const int pages = pageVector.count();
if ( pages < 1 )
{
foreach ( MiniBar *miniBar, m_miniBars )
for ( MiniBar *miniBar : qAsConst(m_miniBars) )
{
miniBar->setEnabled( false );
}
......@@ -88,7 +88,7 @@ void MiniBarLogic::notifySetup( const QVector< Okular::Page * > & pageVector, in
}
bool labelsDiffer = false;
foreach(const Okular::Page * page, pageVector)
for (const Okular::Page * page : pageVector)
{
if (!page->label().isEmpty())
{
......@@ -101,7 +101,7 @@ void MiniBarLogic::notifySetup( const QVector< Okular::Page * > & pageVector, in
const QString pagesString = QString::number( pages );
foreach ( MiniBar *miniBar, m_miniBars )
for ( MiniBar *miniBar : qAsConst(m_miniBars) )
{
// resize width of widgets
miniBar->resizeForPage( pages );
......@@ -135,7 +135,7 @@ void MiniBarLogic::notifyCurrentPageChanged( int previousPage, int currentPage )
const QString pageNumber = QString::number( currentPage + 1 );
const QString pageLabel = m_document->page( currentPage )->label();
foreach ( MiniBar *miniBar, m_miniBars )
for ( MiniBar *miniBar : qAsConst(m_miniBars) )
{
// update prev/next button state
miniBar->m_prevButton->setEnabled( currentPage > 0 );
......@@ -437,7 +437,7 @@ void PageLabelEdit::setPageLabels( const QVector<Okular::Page *> &pageVector )
{
m_labelPageMap.clear();
completionObject()->clear();
foreach(const Okular::Page * page, pageVector)
for (const Okular::Page * page : pageVector)
{
if ( !page->label().isEmpty() )
{
......
......@@ -621,7 +621,7 @@ do { \
ADD_VIEWMODE_ACTION( i18n( "Facing Pages (Center First Page)" ), "view_render_mode_facing_center_first", (int)Okular::Settings::EnumViewMode::FacingFirstCentered );
ADD_VIEWMODE_ACTION( i18n( "Overview" ), "view_render_mode_overview", (int)Okular::Settings::EnumViewMode::Summary );
const QList<QAction *> viewModeActions = d->aViewMode->menu()->actions();
foreach(QAction *viewModeAction, viewModeActions)
for (QAction *viewModeAction : viewModeActions)
{
if (viewModeAction->data().toInt() == Okular::Settings::viewMode())
{
......@@ -811,7 +811,7 @@ void PageView::openAnnotationWindow( Okular::Annotation * annotation, int pageNu
// find the annot window
AnnotWindow* existWindow = nullptr;
foreach(AnnotWindow *aw, d->m_annowindows)
for (AnnotWindow *aw : qAsConst(d->m_annowindows))
{
if ( aw->annotation() == annotation )
{
......@@ -1054,7 +1054,8 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
{
// even if the document has not changed, allowfillforms may have
// changed, so update all fields' "canBeFilled" flag
foreach ( FormWidgetIface * w, d->items[i]->formWidgets() )
const QSet<FormWidgetIface *> formWidgetsList = d->items[i]->formWidgets();
for ( FormWidgetIface *w : formWidgetsList )
w->setCanBeFilled( allowfillforms );
}
}
......@@ -1069,7 +1070,7 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
// around so we can look for the new ones using unique ids, etc
d->mouseAnnotation->updateAnnotationPointers();
foreach(AnnotWindow *aw, d->m_annowindows)
for (AnnotWindow *aw : qAsConst(d->m_annowindows))
{
Okular::Annotation *newA = d->document->page( aw->pageNumber() )->annotation( aw->annotation()->uniqueName() );
aw->updateAnnotation( newA );
......@@ -1081,7 +1082,7 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
{
PageViewItem *item = d->items[i];
const QSet<FormWidgetIface*> fws = item->formWidgets();
foreach ( FormWidgetIface * w, fws )
for ( FormWidgetIface *w : fws )
{
Okular::FormField *f = Okular::PagePrivate::findEquivalentForm( d->document->page( i ), w->formField() );
if (f)
......@@ -1099,7 +1100,8 @@ void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setup
// For the video widgets we don't really care about reusing them since they don't contain much info so just
// create them again
createAnnotationsVideoWidgets( item, pageSet[i]->annotations() );
Q_FOREACH ( VideoWidget *vw, item->videoWidgets() )
const QHash<Okular::Movie *, VideoWidget *> videoWidgets = item->videoWidgets();
for ( VideoWidget *vw : videoWidgets )
{
const Okular::NormalizedRect r = vw->normGeometry();
vw->setGeometry(
......@@ -1213,7 +1215,8 @@ void PageView::updateActionState( bool haspages, bool documentChanged, bool hasf
if ( pageSizes && documentChanged )
{
QStringList items;
foreach ( const Okular::PageSize &p, d->document->pageSizes() )
const QList<Okular::PageSize> sizes = d->document->pageSizes();
for ( const Okular::PageSize &p : sizes )
items.append( p.name() );
d->aPageSizes->setItems( items );
}
......@@ -1502,13 +1505,15 @@ void PageView::notifyCurrentPageChanged( int previous, int current )
PageViewItem * item = d->items.at( previous );
if ( item )
{
Q_FOREACH ( VideoWidget *videoWidget, item->videoWidgets() )
const QHash<Okular::Movie *, VideoWidget *> videoWidgetsList = item->videoWidgets();
for ( VideoWidget *videoWidget : videoWidgetsList )
videoWidget->pageLeft();
}
// On close, run the widget scripts, needed for running animated PDF
const Okular::Page *page = d->document->page( previous );
foreach( Okular::Annotation *annotation, page->annotations() )
const QLinkedList<Okular::Annotation *> annotations = page->annotations();
for ( Okular::Annotation *annotation : annotations )
{
if ( annotation->subType() == Okular::Annotation::AWidget )
{
......@@ -1524,7 +1529,8 @@ void PageView::notifyCurrentPageChanged( int previous, int current )
PageViewItem * item = d->items.at( current );
if ( item )
{
Q_FOREACH ( VideoWidget *videoWidget, item->videoWidgets() )
const QHash<Okular::Movie *, VideoWidget *> videoWidgetsList = item->videoWidgets();
for ( VideoWidget *videoWidget : videoWidgetsList )
videoWidget->pageEntered();
}
......@@ -1534,7 +1540,8 @@ void PageView::notifyCurrentPageChanged( int previous, int current )
// Opening any widget scripts, needed for running animated PDF
const Okular::Page *page = d->document->page( current );
foreach( Okular::Annotation *annotation, page->annotations() )
const QLinkedList<Okular::Annotation *> annotations = page->annotations();
for ( Okular::Annotation *annotation : annotations )
{
if ( annotation->subType() == Okular::Annotation::AWidget )
{
......@@ -1837,7 +1844,7 @@ void PageView::paintEvent(QPaintEvent *pe)
pixmapPainter.drawRect( selectionRect.adjusted( 0, 0, -1, -1 ) );
}
// 2b) Layer 1b: paint (blend) transparent selection (table)
foreach (const TableSelectionPart &tsp, d->tableSelectionParts) {
for (const TableSelectionPart &tsp : qAsConst(d->tableSelectionParts)) {
QRect selectionPartRect = tsp.rectInItem.geometry(tsp.item->uncroppedWidth(), tsp.item->uncroppedHeight());
selectionPartRect.translate( tsp.item->uncroppedGeometry().topLeft () );
QRect selectionPartRectInternal = selectionPartRect;
......@@ -1899,7 +1906,7 @@ void PageView::paintEvent(QPaintEvent *pe)
screenPainter.drawRect( selectionRect );
}
// 2b) Layer 1b: paint opaque selection (table)
foreach (const TableSelectionPart &tsp, d->tableSelectionParts) {
for (const TableSelectionPart &tsp : qAsConst(d->tableSelectionParts)) {
QRect selectionPartRect = tsp.rectInItem.geometry(tsp.item->uncroppedWidth(), tsp.item->uncroppedHeight());
selectionPartRect.translate( tsp.item->uncroppedGeometry().topLeft () );
QRect selectionPartRectInternal = selectionPartRect;
......@@ -1937,12 +1944,12 @@ void PageView::drawTableDividers(QPainter * screenPainter)
p.setStyle( Qt::DashLine );
screenPainter->setPen( p );
}
foreach (const TableSelectionPart &tsp, d->tableSelectionParts) {
for (const TableSelectionPart &tsp : qAsConst(d->tableSelectionParts)) {
QRect selectionPartRect = tsp.rectInItem.geometry(tsp.item->uncroppedWidth(), tsp.item->uncroppedHeight());
selectionPartRect.translate( tsp.item->uncroppedGeometry().topLeft () );
QRect selectionPartRectInternal = selectionPartRect;
selectionPartRectInternal.adjust( 1, 1, -1, -1 );
foreach(double col, d->tableSelectionCols) {
for (double col : qAsConst(d->tableSelectionCols)) {
if (col >= tsp.rectInSelection.left && col <= tsp.rectInSelection.right) {
col = (col - tsp.rectInSelection.left) / (tsp.rectInSelection.right - tsp.rectInSelection.left);
const int x = selectionPartRect.left() + col * selectionPartRect.width() + 0.5;
......@@ -1952,7 +1959,7 @@ void PageView::drawTableDividers(QPainter * screenPainter)
);
}
}
foreach(double row, d->tableSelectionRows) {
for (double row : qAsConst(d->tableSelectionRows)) {
if (row >= tsp.rectInSelection.top && row <= tsp.rectInSelection.bottom) {
row = (row - tsp.rectInSelection.top) / (tsp.rectInSelection.bottom - tsp.rectInSelection.top);
const int y = selectionPartRect.top() + row * selectionPartRect.height() + 0.5;
......@@ -2422,7 +2429,7 @@ void PageView::mousePressEvent( QMouseEvent * e )
{
AnnotationPopup popup( d->document, AnnotationPopup::MultiAnnotationMode, this );
foreach ( const Okular::ObjectRect * orect, orects )
for ( const Okular::ObjectRect * orect : orects )
{
Okular::Annotation * ann = ( (Okular::AnnotationObjectRect *)orect )->annotation();
if ( ann && (ann->subType() != Okular::Annotation::AWidget) )
......@@ -2471,7 +2478,7 @@ void PageView::mousePressEvent( QMouseEvent * e )
selectionStart( eventPos, palette().color( QPalette::Active, QPalette::Highlight ).lighter( 120 ), false );
} else {
QRect updatedRect;
foreach (const TableSelectionPart &tsp, d->tableSelectionParts) {
for (const TableSelectionPart &tsp : qAsConst(d->tableSelectionParts)) {
QRect selectionPartRect = tsp.rectInItem.geometry(tsp.item->uncroppedWidth(), tsp.item->uncroppedHeight());
selectionPartRect.translate( tsp.item->uncroppedGeometry().topLeft () );
......@@ -3068,7 +3075,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
Okular::NormalizedRect cell(xs[c], ys[r], xs[c+1], ys[r+1]);
if (c) selText += QLatin1Char('\t');
QString txt;
foreach (const TableSelectionPart &tsp, d->tableSelectionParts) {
for (const TableSelectionPart &tsp : qAsConst(d->tableSelectionParts)) {
// first, crop the cell to this part
if (!tsp.rectInSelection.intersects(cell))
continue;
......@@ -3232,7 +3239,7 @@ void PageView::guessTableDividers()
{
QList< QPair<double, int> > colTicks, rowTicks, colSelectionTicks, rowSelectionTicks;
foreach ( const TableSelectionPart& tsp, d->tableSelectionParts )
for ( const TableSelectionPart& tsp : qAsConst(d->tableSelectionParts) )
{
// add ticks for the edges of this area...
colSelectionTicks.append( qMakePair( tsp.rectInSelection.left, +1 ) );
......@@ -3245,7 +3252,7 @@ void PageView::guessTableDividers()
rects.append( tsp.rectInItem );
const Okular::TextEntity::List words = tsp.item->page()->words( &rects, Okular::TextPage::CentralPixelTextAreaInclusionBehaviour );
foreach (Okular::TextEntity *te, words)
for (const Okular::TextEntity *te : words)
{
if (te->text().isEmpty()) {
delete te;
......@@ -3534,7 +3541,7 @@ QList< Okular::RegularAreaRect * > PageView::textSelections( const QPoint& start
QList< Okular::RegularAreaRect * > ret;
QSet< int > affectedItemsSet;
QRect selectionRect = QRect( start, end ).normalized();
foreach( PageViewItem * item, d->items )
for ( const PageViewItem *item : qAsConst(d->items) )
{
if ( item->isVisible() && selectionRect.intersects( item->croppedGeometry() ) )
affectedItemsSet.insert( item->pageNumber() );
......@@ -3550,7 +3557,7 @@ QList< Okular::RegularAreaRect * > PageView::textSelections( const QPoint& start
int tmpmin = d->document->pages();
int tmpmax = 0;
foreach( int p, affectedItemsSet )
for ( const int p : qAsConst(affectedItemsSet) )
{
if ( p < tmpmin ) tmpmin = p;
if ( p > tmpmax ) tmpmax = p;
......@@ -3595,7 +3602,7 @@ QList< Okular::RegularAreaRect * > PageView::textSelections( const QPoint& start
affectedItemsIds.removeFirst();
affectedItemsIds.removeLast();
// item between the two above
foreach( int page, affectedItemsIds )
for ( const int page : qAsConst(affectedItemsIds) )
{
ret.append( textSelectionForItem( d->items[ page ] ) );
}
......@@ -3957,12 +3964,12 @@ void PageView::updateSelection( const QPoint & pos )
const QSet< int > noMoreSelectedPages = d->pagesWithTextSelection - pagesWithSelectionSet;
// clear the selection from pages not selected anymore
foreach( int p, noMoreSelectedPages )
for ( int p : noMoreSelectedPages )
{
d->document->setPageTextSelection( p, nullptr, QColor() );
}
// set the new selection for the selected pages
foreach( int p, pagesWithSelectionSet )
for ( int p : qAsConst(pagesWithSelectionSet) )
{
d->document->setPageTextSelection( p, selections[ p - first ], palette().color( QPalette::Active, QPalette::Highlight ) );
}
......@@ -4028,7 +4035,7 @@ void PageView::selectionClear(const ClearMode mode)
d->tableSelectionCols.clear();
d->tableSelectionRows.clear();
d->tableDividersGuessed = false;
foreach (const TableSelectionPart &tsp, d->tableSelectionParts) {
for (const TableSelectionPart &tsp : qAsConst(d->tableSelectionParts)) {
QRect selectionPartRect = tsp.rectInItem.geometry(tsp.item->uncroppedWidth(), tsp.item->uncroppedHeight());
selectionPartRect.translate( tsp.item->uncroppedGeometry().topLeft () );
// should check whether this is on-screen here?
......@@ -4524,7 +4531,7 @@ void PageView::addWebShortcutsMenu( QMenu * menu, const QString & text )
QAction *action = nullptr;
foreach( const QString &searchProvider, searchProviders )
for ( const QString &searchProvider : searchProviders )
{
action = new QAction( searchProvider, webShortcutsMenu );
action->setIcon( QIcon::fromTheme( filterData.iconNameForPreferredSearchProvider( searchProvider ) ) );
......@@ -4872,14 +4879,16 @@ void PageView::slotRequestVisiblePixmaps( int newValue )
QVector< Okular::VisiblePageRect * > visibleRects;
for ( PageViewItem * i : qAsConst( d->items ) )
{
foreach( FormWidgetIface *fwi, i->formWidgets() )
const QSet<FormWidgetIface *> formWidgetsList = i->formWidgets();
for ( FormWidgetIface *fwi : formWidgetsList)
{
Okular::NormalizedRect r = fwi->rect();
fwi->moveTo(
qRound( i->uncroppedGeometry().left() + i->uncroppedWidth() * r.left ) + 1 - viewportRect.left(),
qRound( i->uncroppedGeometry().top() + i->uncroppedHeight() * r.top ) + 1 - viewportRect.top() );
}
Q_FOREACH ( VideoWidget *vw, i->videoWidgets() )
const QHash<Okular::Movie *, VideoWidget *> videoWidgets = i->videoWidgets();
for ( VideoWidget *vw : videoWidgets )
{
const Okular::NormalizedRect r = vw->normGeometry();
vw->move(
......@@ -5406,7 +5415,7 @@ void PageView::slotPageSizes( int newsize )
// From Okular::Settings::EnumTrimMode
void PageView::updateTrimMode( int except_id ) {
const QList<QAction *> trimModeActions = d->aTrimMode->menu()->actions();
foreach(QAction *trimModeAction, trimModeActions)
for (QAction *trimModeAction : trimModeActions)
{
if (trimModeAction->data().toInt() != except_id)
trimModeAction->setChecked( false );
......@@ -5511,7 +5520,7 @@ void PageView::slotFormChanged( int pageNumber )
void PageView::slotRefreshPage()
{
foreach(int req, d->refreshPages)
for (int req : qAsConst(d->refreshPages))
{
QMetaObject::invokeMethod( d->document, "refreshPixmaps", Qt::QueuedConnection,
Q_ARG( int, req ) );
......@@ -5671,7 +5680,7 @@ void PageView::slotFitWindowToPage()
{
const PageViewItem *currentPageItem = nullptr;
QSize viewportSize = viewport()->size();
foreach ( const PageViewItem * pageItem, d->items )
for ( const PageViewItem *pageItem : qAsConst(d->items) )
{
if ( pageItem->isVisible() )
{
......@@ -5711,7 +5720,8 @@ void PageView::highlightSignatureFormWidget( const Okular::FormFieldSignature *f
QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd();
for ( ; dIt != dEnd; ++dIt )
{
foreach ( auto fw, (*dIt)->formWidgets() )
const QSet<FormWidgetIface *> fwi = (*dIt)->formWidgets();
for ( FormWidgetIface *fw : fwi )
{
if ( fw->formField() == form )
{
......
......@@ -537,7 +537,7 @@ class TextSelectorEngine : public AnnotatorEngine
{
const QList<QRect> geom = newselection->geometry( (int)xScale, (int)yScale );
QRect newrect;
Q_FOREACH ( const QRect& r, geom )
for ( const QRect &r : geom )
{
if ( newrect.isNull() )
newrect = r;
......@@ -564,7 +564,7 @@ class TextSelectorEngine : public AnnotatorEngine
QColor col = m_engineColor;
col.setAlphaF( 0.5 );
painter->setBrush( col );
foreach( const Okular::NormalizedRect & r, *selection )
for ( const Okular::NormalizedRect &r : qAsConst(*selection) )
{
painter->drawRect( r.geometry( (int)xScale, (int)yScale ) );
}
......@@ -611,7 +611,7 @@ class TextSelectorEngine : public AnnotatorEngine
Okular::HighlightAnnotation * ha = new Okular::HighlightAnnotation();
ha->setHighlightType( type );
ha->setBoundingRectangle( Okular::NormalizedRect( rect, item()->uncroppedWidth(), item()->uncroppedHeight() ) );
foreach ( const Okular::NormalizedRect & r, *selection )
for ( const Okular::NormalizedRect &r : qAsConst(*selection) )
{
Okular::HighlightAnnotation::Quad q;
q.setCapStart( false );
......@@ -677,7 +677,7 @@ void PageViewAnnotator::reparseConfig()
// Populate m_toolsDefinition
QDomDocument doc;
m_toolsDefinition = doc.createElement( QStringLiteral("annotatingTools") );
foreach ( const QString &toolXml, userTools )
for ( const QString &toolXml : userTools )
{
QDomDocument entryParser;
if ( entryParser.setContent( toolXml ) )
......@@ -857,9 +857,9 @@ QRect PageViewAnnotator::performRouteMouseOrTabletEvent(const AnnotatorEngine::E
if ( m_engine->creationCompleted() )
{
// apply engine data to the Annotation's and reset engine
QList< Okular::Annotation* > annotations = m_engine->end();
const QList< Okular::Annotation* > annotations = m_engine->end();
// attach the newly filled annotations to the page
foreach ( Okular::Annotation * annotation, annotations )
for ( Okular::Annotation *annotation : annotations )
{
if ( !annotation ) continue;
......
......@@ -305,7 +305,7 @@ void MouseAnnotation::routePaint( QPainter * painter, const QRect & paintRect )
{
painter->setPen(borderColor);
painter->setBrush(fillColor);
Q_FOREACH( const ResizeHandle & handle, m_resizeHandleList )
for ( const ResizeHandle &handle : qAsConst(m_resizeHandleList) )
{
QRect rect = getHandleRect( handle, m_focusedAnnotation );
painter->drawRect( rect );
......@@ -603,7 +603,7 @@ MouseAnnotation::ResizeHandle MouseAnnotation::getHandleAt( const QPoint & event
if ( ad.annotation->canBeResized() )
{
Q_FOREACH( const ResizeHandle & handle, m_resizeHandleList )
for ( const ResizeHandle &handle : m_resizeHandleList )
{
const QRect rect = getHandleRect( handle, ad );
if ( rect.contains( eventPos ) )
......
......@@ -140,14 +140,14 @@ void PageViewItem::setWHZC( int w, int h, double z, const Okular:: NormalizedRec
m_crop = c;
m_uncroppedGeometry.setWidth( qRound( w / ( c.right - c.left ) ) );