Merge lp:~adamreichold/qpdfview/add-split-view into lp:qpdfview

Proposed by Adam Reichold
Status: Merged
Merged at revision: 2043
Proposed branch: lp:~adamreichold/qpdfview/add-split-view
Merge into: lp:qpdfview
Diff against target: 2893 lines (+918/-511)
34 files modified
sources/bookmarkmodel.cpp (+5/-8)
sources/bookmarkmodel.h (+9/-2)
sources/database.cpp (+2/-2)
sources/database.h (+2/-2)
sources/djvumodel.cpp (+5/-5)
sources/djvumodel.h (+1/-1)
sources/documentview.cpp (+35/-20)
sources/documentview.h (+7/-5)
sources/fitzmodel.cpp (+1/-1)
sources/fitzmodel.h (+1/-1)
sources/formfieldwidgets.cpp (+1/-1)
sources/imagemodel.cpp (+3/-3)
sources/imagemodel.h (+3/-3)
sources/mainwindow.cpp (+510/-333)
sources/mainwindow.h (+35/-16)
sources/miscellaneous.cpp (+109/-3)
sources/miscellaneous.h (+48/-5)
sources/model.h (+3/-3)
sources/pageitem.cpp (+5/-5)
sources/pageitem.h (+7/-7)
sources/pdfmodel.cpp (+44/-26)
sources/pdfmodel.h (+1/-1)
sources/psmodel.cpp (+1/-1)
sources/psmodel.h (+1/-1)
sources/recentlyclosedmenu.cpp (+2/-2)
sources/recentlyusedmenu.cpp (+3/-3)
sources/searchmodel.cpp (+14/-11)
sources/searchmodel.h (+1/-1)
sources/settings.cpp (+24/-14)
sources/settings.h (+20/-16)
sources/settingsdialog.cpp (+7/-2)
sources/settingsdialog.h (+2/-1)
sources/tileitem.cpp (+4/-4)
sources/tileitem.h (+2/-2)
To merge this branch: bzr merge lp:~adamreichold/qpdfview/add-split-view
Reviewer Review Type Date Requested Status
Adam Reichold Pending
Review via email: mp+322611@code.launchpad.net

Description of the change

Adds basic support for split views, i.e. tabs that actually contain several tabs managed by QSplitter. This is done by adding context menu actions to split an existing tab and some refactoring that allows the main window to handle the fact that there might be more than a one tab behind a single tab widget index. The currently active tab in such a split view is tracked using the keyboard focus so that there should also always be one current tab both w.r.t. to the tab widget as well as the split views within.

To post a comment you must log in.
2050. By Adam Reichold

Instead of disconnecting and reconnecting slots to avoid redundant updates, block the signle relevant slot using a simple flag variable and an RAII helper.

2051. By Adam Reichold

Add an action to close only the current view and make sure to wire up a newly added tab's signals.

2052. By Adam Reichold

Tighten up the tab interaction in a few more places.

2053. By Adam Reichold

Fix usage of QList in the bookmark and search models and various small performance issues reported by the clazy tool using the checks of "level0,level1,level2,no-missing-qobject-macro,no-qstring-allocations,no-copyable-polymorphic,no-ctor-missing-parent-argument,no-reserve-candidates".

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sources/bookmarkmodel.cpp'
2--- sources/bookmarkmodel.cpp 2015-01-10 23:45:56 +0000
3+++ sources/bookmarkmodel.cpp 2017-04-19 21:02:47 +0000
4@@ -70,10 +70,10 @@
5
6 void BookmarkModel::addBookmark(const BookmarkItem& bookmark)
7 {
8- QList< BookmarkItem >::iterator at = qBinaryFind(m_bookmarks.begin(), m_bookmarks.end(), bookmark.page);
9- int row = at - m_bookmarks.begin();
10+ const QVector< BookmarkItem >::iterator at = qLowerBound(m_bookmarks.begin(), m_bookmarks.end(), bookmark.page);
11+ const int row = at - m_bookmarks.begin();
12
13- if(at != m_bookmarks.end())
14+ if(at != m_bookmarks.end() && at->page == bookmark.page)
15 {
16 *at = bookmark;
17
18@@ -81,9 +81,6 @@
19 }
20 else
21 {
22- at = qUpperBound(m_bookmarks.begin(), m_bookmarks.end(), bookmark.page);
23- row = at - m_bookmarks.begin();
24-
25 beginInsertRows(QModelIndex(), row, row);
26
27 m_bookmarks.insert(at, bookmark);
28@@ -94,7 +91,7 @@
29
30 void BookmarkModel::removeBookmark(const BookmarkItem& bookmark)
31 {
32- const QList< BookmarkItem >::iterator at = qBinaryFind(m_bookmarks.begin(), m_bookmarks.end(), bookmark.page);
33+ const QVector< BookmarkItem >::iterator at = qBinaryFind(m_bookmarks.begin(), m_bookmarks.end(), bookmark.page);
34 const int row = at - m_bookmarks.begin();
35
36 if(at != m_bookmarks.end())
37@@ -109,7 +106,7 @@
38
39 void BookmarkModel::findBookmark(BookmarkItem& bookmark) const
40 {
41- const QList< BookmarkItem >::const_iterator at = qBinaryFind(m_bookmarks.constBegin(), m_bookmarks.constEnd(), bookmark.page);
42+ const QVector< BookmarkItem >::const_iterator at = qBinaryFind(m_bookmarks.constBegin(), m_bookmarks.constEnd(), bookmark.page);
43
44 if(at != m_bookmarks.constEnd())
45 {
46
47=== modified file 'sources/bookmarkmodel.h'
48--- sources/bookmarkmodel.h 2015-02-08 17:20:20 +0000
49+++ sources/bookmarkmodel.h 2017-04-19 21:02:47 +0000
50@@ -38,7 +38,7 @@
51 QString comment;
52 QDateTime modified;
53
54- BookmarkItem(int page, const QString& label = QString(), const QString& comment = QString(), const QDateTime& modified = QDateTime::currentDateTime()) :
55+ BookmarkItem(int page = -1, const QString& label = QString(), const QString& comment = QString(), const QDateTime& modified = QDateTime::currentDateTime()) :
56 page(page),
57 label(label),
58 comment(comment),
59@@ -46,6 +46,13 @@
60
61 };
62
63+} // namespace qpdfview
64+
65+Q_DECLARE_TYPEINFO(qpdfview::BookmarkItem, Q_MOVABLE_TYPE);
66+
67+namespace qpdfview
68+{
69+
70 class BookmarkModel : public QAbstractListModel
71 {
72 Q_OBJECT
73@@ -88,7 +95,7 @@
74 static QHash< QString, BookmarkModel* > s_instances;
75 BookmarkModel(QObject* parent = 0);
76
77- QList< BookmarkItem > m_bookmarks;
78+ QVector< BookmarkItem > m_bookmarks;
79
80 };
81
82
83=== modified file 'sources/database.cpp'
84--- sources/database.cpp 2016-05-04 13:47:11 +0000
85+++ sources/database.cpp 2017-04-19 21:02:47 +0000
86@@ -1,7 +1,7 @@
87 /*
88
89 Copyright 2014 S. Razi Alavizadeh
90-Copyright 2012-2015 Adam Reichold
91+Copyright 2012-2017 Adam Reichold
92 Copyright 2012 MichaƂ Trybus
93
94 This file is part of qpdfview.
95@@ -392,7 +392,7 @@
96 #endif // WITH_SQL
97 }
98
99-void Database::saveTabs(const QList< DocumentView* >& tabs)
100+void Database::saveTabs(const QVector< DocumentView* >& tabs)
101 {
102 #ifdef WITH_SQL
103
104
105=== modified file 'sources/database.h'
106--- sources/database.h 2016-05-04 13:47:11 +0000
107+++ sources/database.h 2017-04-19 21:02:47 +0000
108@@ -1,7 +1,7 @@
109 /*
110
111 Copyright 2014 S. Razi Alavizadeh
112-Copyright 2013-2015 Adam Reichold
113+Copyright 2013-2017 Adam Reichold
114
115 This file is part of qpdfview.
116
117@@ -56,7 +56,7 @@
118 };
119
120 void restoreTabs(const RestoreTab& restoreTab);
121- void saveTabs(const QList< DocumentView* >& tabs);
122+ void saveTabs(const QVector< DocumentView* >& tabs);
123 void clearTabs();
124
125 void restoreBookmarks();
126
127=== modified file 'sources/djvumodel.cpp'
128--- sources/djvumodel.cpp 2017-04-02 09:36:22 +0000
129+++ sources/djvumodel.cpp 2017-04-19 21:02:47 +0000
130@@ -118,7 +118,7 @@
131 }
132 }
133
134-QPainterPath loadLinkBoundary(const QString& type, miniexp_t boundaryExp, const QSizeF& size)
135+QPainterPath loadLinkBoundary(const QString& type, miniexp_t boundaryExp, QSizeF size)
136 {
137 QPainterPath boundary;
138
139@@ -215,7 +215,7 @@
140 }
141 }
142
143-QList< Link* > loadLinks(miniexp_t linkExp, const QSizeF& size, int index, const QHash< QString, int >& pageByName)
144+QList< Link* > loadLinks(miniexp_t linkExp, QSizeF size, int index, const QHash< QString, int >& pageByName)
145 {
146 QList< Link* > links;
147
148@@ -257,7 +257,7 @@
149 return links;
150 }
151
152-QString loadText(miniexp_t textExp, const QSizeF& size, const QRectF& rect)
153+QString loadText(miniexp_t textExp, QSizeF size, const QRectF& rect)
154 {
155 if(miniexp_length(textExp) < 6 && !miniexp_symbolp(miniexp_car(textExp)))
156 {
157@@ -297,7 +297,7 @@
158 return QString();
159 }
160
161-QList< QRectF > findText(miniexp_t pageTextExp, const QSizeF& size, const QTransform& transform, const QStringList& words, bool matchCase, bool wholeWords)
162+QList< QRectF > findText(miniexp_t pageTextExp, QSizeF size, const QTransform& transform, const QStringList& words, bool matchCase, bool wholeWords)
163 {
164 if(words.isEmpty())
165 {
166@@ -514,7 +514,7 @@
167 return 72.0 / m_resolution * m_size;
168 }
169
170-QImage DjVuPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const
171+QImage DjVuPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const
172 {
173 LOCK_PAGE
174
175
176=== modified file 'sources/djvumodel.h'
177--- sources/djvumodel.h 2017-04-02 09:36:22 +0000
178+++ sources/djvumodel.h 2017-04-19 21:02:47 +0000
179@@ -51,7 +51,7 @@
180
181 QSizeF size() const;
182
183- QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const;
184+ QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const;
185
186 QString label() const;
187
188
189=== modified file 'sources/documentview.cpp'
190--- sources/documentview.cpp 2017-04-02 09:36:22 +0000
191+++ sources/documentview.cpp 2017-04-19 21:02:47 +0000
192@@ -240,7 +240,7 @@
193
194 #ifdef WITH_SYNCTEX
195
196-DocumentView::SourceLink scanForSourceLink(const QString& filePath, const int page, const QPointF& pos)
197+DocumentView::SourceLink scanForSourceLink(const QString& filePath, const int page, QPointF pos)
198 {
199 DocumentView::SourceLink sourceLink;
200
201@@ -265,7 +265,7 @@
202
203 #endif // WITH_SYNCTEX
204
205-inline bool modifiersAreActive(const QWheelEvent* event, const Qt::KeyboardModifiers& modifiers)
206+inline bool modifiersAreActive(const QWheelEvent* event, Qt::KeyboardModifiers modifiers)
207 {
208 if(modifiers == Qt::NoModifier)
209 {
210@@ -658,6 +658,27 @@
211 namespace qpdfview
212 {
213
214+class DocumentView::VerticalScrollBarChangedBlocker
215+{
216+ Q_DISABLE_COPY(VerticalScrollBarChangedBlocker)
217+
218+private:
219+ DocumentView* const that;
220+
221+public:
222+
223+ VerticalScrollBarChangedBlocker(DocumentView* that) : that(that)
224+ {
225+ that->m_verticalScrollBarChangedBlocked = true;
226+ }
227+
228+ ~VerticalScrollBarChangedBlocker()
229+ {
230+ that->m_verticalScrollBarChangedBlocked = false;
231+ }
232+
233+};
234+
235 Settings* DocumentView::s_settings = 0;
236 ShortcutHandler* DocumentView::s_shortcutHandler = 0;
237 SearchModel* DocumentView::s_searchModel = 0;
238@@ -690,6 +711,7 @@
239 m_thumbnailsScene(0),
240 m_outlineModel(0),
241 m_propertiesModel(0),
242+ m_verticalScrollBarChangedBlocked(false),
243 m_currentResult(),
244 m_searchTask(0)
245 {
246@@ -710,10 +732,11 @@
247
248 setScene(new QGraphicsScene(this));
249
250+ setFocusPolicy(Qt::StrongFocus);
251 setAcceptDrops(false);
252 setDragMode(QGraphicsView::ScrollHandDrag);
253
254- reconnectVerticalScrollBar();
255+ connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(on_verticalScrollBar_valueChanged()));
256
257 m_thumbnailsScene = new QGraphicsScene(this);
258
259@@ -1215,7 +1238,7 @@
260 }
261 }
262
263-void DocumentView::setThumbnailsViewportSize(const QSize& thumbnailsViewportSize)
264+void DocumentView::setThumbnailsViewportSize(QSize thumbnailsViewportSize)
265 {
266 if(m_thumbnailsViewportSize != thumbnailsViewportSize)
267 {
268@@ -1307,7 +1330,7 @@
269 return url;
270 }
271
272-DocumentView::SourceLink DocumentView::sourceLink(const QPoint& pos)
273+DocumentView::SourceLink DocumentView::sourceLink(QPoint pos)
274 {
275 SourceLink sourceLink;
276
277@@ -1795,7 +1818,7 @@
278
279 void DocumentView::on_verticalScrollBar_valueChanged()
280 {
281- if(!m_continuousMode)
282+ if(m_verticalScrollBarChangedBlocked || !m_continuousMode)
283 {
284 return;
285 }
286@@ -1989,7 +2012,7 @@
287 jumpToPage(page, false, rect.left(), rect.top());
288 }
289
290-void DocumentView::on_pages_openInSourceEditor(int page, const QPointF& pos)
291+void DocumentView::on_pages_openInSourceEditor(int page, QPointF pos)
292 {
293 #ifdef WITH_SYNCTEX
294
295@@ -2630,16 +2653,6 @@
296 }
297 }
298
299-void DocumentView::disconnectVerticalScrollBar()
300-{
301- disconnect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(on_verticalScrollBar_valueChanged()));
302-}
303-
304-void DocumentView::reconnectVerticalScrollBar()
305-{
306- connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(on_verticalScrollBar_valueChanged()));
307-}
308-
309 void DocumentView::prepareDocument(Model::Document* document, const QVector< Model::Page* >& pages)
310 {
311 m_prefetchTimer->blockSignals(true);
312@@ -3006,9 +3019,11 @@
313
314 m_highlight->setVisible(true);
315
316- disconnectVerticalScrollBar();
317- centerOn(m_highlight);
318- reconnectVerticalScrollBar();
319+ {
320+ VerticalScrollBarChangedBlocker verticalScrollBarChangedBlocker(this);
321+
322+ centerOn(m_highlight);
323+ }
324
325 viewport()->update();
326 }
327
328=== modified file 'sources/documentview.h'
329--- sources/documentview.h 2016-03-25 17:45:56 +0000
330+++ sources/documentview.h 2017-04-19 21:02:47 +0000
331@@ -127,7 +127,7 @@
332 void setRubberBandMode(RubberBandMode rubberBandMode);
333
334 QSize thumbnailsViewportSize() const { return m_thumbnailsViewportSize; }
335- void setThumbnailsViewportSize(const QSize& thumbnailsViewportSize);
336+ void setThumbnailsViewportSize(QSize thumbnailsViewportSize);
337
338 Qt::Orientation thumbnailsOrientation() const { return m_thumbnailsOrientation; }
339 void setThumbnailsOrientation(Qt::Orientation thumbnailsOrientation);
340@@ -162,7 +162,7 @@
341
342 };
343
344- SourceLink sourceLink(const QPoint& pos);
345+ SourceLink sourceLink(QPoint pos);
346 void openInSourceEditor(const SourceLink& sourceLink);
347
348 signals:
349@@ -260,7 +260,7 @@
350 void on_pages_rubberBandFinished();
351
352 void on_pages_zoomToSelection(int page, const QRectF& rect);
353- void on_pages_openInSourceEditor(int page, const QPointF& pos);
354+ void on_pages_openInSourceEditor(int page, QPointF pos);
355
356 void on_pages_wasModified();
357
358@@ -347,8 +347,10 @@
359 void loadDocumentDefaults();
360
361 void adjustScrollBarPolicy();
362- void disconnectVerticalScrollBar();
363- void reconnectVerticalScrollBar();
364+
365+ bool m_verticalScrollBarChangedBlocked;
366+
367+ class VerticalScrollBarChangedBlocker;
368
369 void prepareDocument(Model::Document* document, const QVector< Model::Page* >& pages);
370 void preparePages();
371
372=== modified file 'sources/fitzmodel.cpp'
373--- sources/fitzmodel.cpp 2017-04-02 09:36:22 +0000
374+++ sources/fitzmodel.cpp 2017-04-19 21:02:47 +0000
375@@ -98,7 +98,7 @@
376 return QSizeF(rect.x1 - rect.x0, rect.y1 - rect.y0);
377 }
378
379-QImage FitzPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const
380+QImage FitzPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const
381 {
382 QMutexLocker mutexLocker(&m_parent->m_mutex);
383
384
385=== modified file 'sources/fitzmodel.h'
386--- sources/fitzmodel.h 2017-04-02 09:36:22 +0000
387+++ sources/fitzmodel.h 2017-04-19 21:02:47 +0000
388@@ -52,7 +52,7 @@
389
390 QSizeF size() const;
391
392- QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const;
393+ QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const;
394
395 QList< Link* > links() const;
396
397
398=== modified file 'sources/formfieldwidgets.cpp'
399--- sources/formfieldwidgets.cpp 2014-10-18 14:25:30 +0000
400+++ sources/formfieldwidgets.cpp 2017-04-19 21:02:47 +0000
401@@ -128,7 +128,7 @@
402
403 if(!m_formField->currentChoices().isEmpty())
404 {
405- setCurrentIndex(m_formField->currentChoices().first());
406+ setCurrentIndex(m_formField->currentChoices().constFirst());
407 }
408
409 connect(this, SIGNAL(currentIndexChanged(int)), SLOT(on_currentIndexChanged(int)));
410
411=== modified file 'sources/imagemodel.cpp'
412--- sources/imagemodel.cpp 2017-04-02 09:36:22 +0000
413+++ sources/imagemodel.cpp 2017-04-19 21:02:47 +0000
414@@ -48,7 +48,7 @@
415 namespace Model
416 {
417
418-ImagePage::ImagePage(QImage image) :
419+ImagePage::ImagePage(const QImage& image) :
420 m_image(image)
421 {
422 }
423@@ -59,7 +59,7 @@
424 m_image.height() * 72.0 / dotsPerInchY(m_image));
425 }
426
427-QImage ImagePage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const
428+QImage ImagePage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const
429 {
430 QTransform transform;
431
432@@ -92,7 +92,7 @@
433 return image;
434 }
435
436-ImageDocument::ImageDocument(QImage image) :
437+ImageDocument::ImageDocument(const QImage& image) :
438 m_image(image)
439 {
440 }
441
442=== modified file 'sources/imagemodel.h'
443--- sources/imagemodel.h 2017-04-02 09:36:22 +0000
444+++ sources/imagemodel.h 2017-04-19 21:02:47 +0000
445@@ -40,12 +40,12 @@
446 public:
447 QSizeF size() const;
448
449- QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const;
450+ QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const;
451
452 private:
453 Q_DISABLE_COPY(ImagePage)
454
455- ImagePage(QImage image);
456+ ImagePage(const QImage& image);
457
458 QImage m_image;
459
460@@ -72,7 +72,7 @@
461 private:
462 Q_DISABLE_COPY(ImageDocument)
463
464- ImageDocument(QImage image);
465+ ImageDocument(const QImage& image);
466
467 QImage m_image;
468
469
470=== modified file 'sources/mainwindow.cpp'
471--- sources/mainwindow.cpp 2017-01-26 15:18:35 +0000
472+++ sources/mainwindow.cpp 2017-04-19 21:02:47 +0000
473@@ -1,8 +1,7 @@
474-
475 /*
476
477 Copyright 2014-2015 S. Razi Alavizadeh
478-Copyright 2012-2016 Adam Reichold
479+Copyright 2012-2017 Adam Reichold
480 Copyright 2014 Dorian Scholz
481 Copyright 2012 MichaƂ Trybus
482 Copyright 2012 Alexander Volkov
483@@ -216,12 +215,69 @@
484
485 };
486
487+DocumentView* findCurrentTab(QObject* const object)
488+{
489+ if(DocumentView* const tab = qobject_cast< DocumentView* >(object))
490+ {
491+ return tab;
492+ }
493+
494+ if(Splitter* const splitter = qobject_cast< Splitter* >(object))
495+ {
496+ return findCurrentTab(splitter->currentWidget());
497+ }
498+
499+ return 0;
500+}
501+
502+QVector< DocumentView* > findAllTabs(QObject* const object)
503+{
504+ QVector< DocumentView* > tabs;
505+
506+ if(DocumentView* const tab = qobject_cast< DocumentView* >(object))
507+ {
508+ tabs.append(tab);
509+ }
510+
511+ if(Splitter* const splitter = qobject_cast< Splitter* >(object))
512+ {
513+ for(int index = 0, count = splitter->count(); index < count; ++index)
514+ {
515+ tabs.append(findAllTabs(splitter->widget(index)));
516+ }
517+ }
518+
519+ return tabs;
520+}
521+
522 } // anonymous
523
524+class MainWindow::CurrentTabChangeBlocker
525+{
526+ Q_DISABLE_COPY(CurrentTabChangeBlocker)
527+
528+private:
529+ MainWindow* const that;
530+
531+public:
532+ CurrentTabChangeBlocker(MainWindow* const that) : that(that)
533+ {
534+ that->m_currentTabChangedBlocked = true;
535+ }
536+
537+ ~CurrentTabChangeBlocker()
538+ {
539+ that->m_currentTabChangedBlocked = false;
540+
541+ that->on_tabWidget_currentChanged(that->m_tabWidget->currentIndex());
542+ }
543+
544+};
545+
546 class MainWindow::RestoreTab : public Database::RestoreTab
547 {
548 private:
549- MainWindow* that;
550+ MainWindow* const that;
551
552 public:
553 RestoreTab(MainWindow* that) : that(that) {}
554@@ -243,7 +299,7 @@
555 class MainWindow::TextValueMapper : public MappingSpinBox::TextValueMapper
556 {
557 private:
558- MainWindow* that;
559+ MainWindow* const that;
560
561 public:
562 TextValueMapper(MainWindow* that) : that(that) {}
563@@ -382,27 +438,30 @@
564
565 bool MainWindow::open(const QString& filePath, int page, const QRectF& highlight, bool quiet)
566 {
567- if(m_tabWidget->currentIndex() != -1)
568+ if(DocumentView* const tab = currentTab())
569 {
570- saveModifications(currentTab());
571-
572- if(currentTab()->open(filePath))
573- {
574- s_settings->mainWindow().setOpenPath(currentTab()->fileInfo().absolutePath());
575- m_recentlyUsedMenu->addOpenAction(currentTab()->fileInfo());
576-
577- m_tabWidget->setTabText(m_tabWidget->currentIndex(), currentTab()->title());
578- m_tabWidget->setTabToolTip(m_tabWidget->currentIndex(), currentTab()->fileInfo().absoluteFilePath());
579-
580- s_database->restorePerFileSettings(currentTab());
581+ if(!saveModifications(tab))
582+ {
583+ return false;
584+ }
585+
586+ if(tab->open(filePath))
587+ {
588+ s_settings->mainWindow().setOpenPath(tab->fileInfo().absolutePath());
589+ m_recentlyUsedMenu->addOpenAction(tab->fileInfo());
590+
591+ m_tabWidget->setCurrentTabText(tab->title());
592+ m_tabWidget->setCurrentTabToolTip(tab->fileInfo().absoluteFilePath());
593+
594+ s_database->restorePerFileSettings(tab);
595 scheduleSaveTabs();
596
597- currentTab()->jumpToPage(page, false);
598- currentTab()->setFocus();
599+ tab->jumpToPage(page, false);
600+ tab->setFocus();
601
602 if(!highlight.isNull())
603 {
604- currentTab()->temporaryHighlight(page, highlight);
605+ tab->temporaryHighlight(page, highlight);
606 }
607
608 return true;
609@@ -421,58 +480,16 @@
610
611 bool MainWindow::openInNewTab(const QString& filePath, int page, const QRectF& highlight, bool quiet)
612 {
613- DocumentView* newTab = new DocumentView(this);
614+ DocumentView* const newTab = new DocumentView(this);
615
616 if(newTab->open(filePath))
617 {
618 s_settings->mainWindow().setOpenPath(newTab->fileInfo().absolutePath());
619 m_recentlyUsedMenu->addOpenAction(newTab->fileInfo());
620
621- const int index = addTab(newTab);
622-
623- QAction* tabAction = new QAction(m_tabWidget->tabText(index), newTab);
624- tabAction->setToolTip(newTab->fileInfo().absoluteFilePath());
625- connect(tabAction, SIGNAL(triggered()), SLOT(on_tabAction_triggered()));
626-
627- tabAction->setData(true); // Flag action for search-as-you-type
628-
629- m_tabsMenu->addAction(tabAction);
630-
631- on_thumbnails_dockLocationChanged(dockWidgetArea(m_thumbnailsDock));
632-
633- connect(newTab, SIGNAL(documentChanged()), SLOT(on_currentTab_documentChanged()));
634- connect(newTab, SIGNAL(documentModified()), SLOT(on_currentTab_documentModified()));
635-
636- connect(newTab, SIGNAL(numberOfPagesChanged(int)), SLOT(on_currentTab_numberOfPagesChaned(int)));
637- connect(newTab, SIGNAL(currentPageChanged(int)), SLOT(on_currentTab_currentPageChanged(int)));
638-
639- connect(newTab, SIGNAL(canJumpChanged(bool,bool)), SLOT(on_currentTab_canJumpChanged(bool,bool)));
640-
641- connect(newTab, SIGNAL(continuousModeChanged(bool)), SLOT(on_currentTab_continuousModeChanged(bool)));
642- connect(newTab, SIGNAL(layoutModeChanged(LayoutMode)), SLOT(on_currentTab_layoutModeChanged(LayoutMode)));
643- connect(newTab, SIGNAL(rightToLeftModeChanged(bool)), SLOT(on_currentTab_rightToLeftModeChanged(bool)));
644- connect(newTab, SIGNAL(scaleModeChanged(ScaleMode)), SLOT(on_currentTab_scaleModeChanged(ScaleMode)));
645- connect(newTab, SIGNAL(scaleFactorChanged(qreal)), SLOT(on_currentTab_scaleFactorChanged(qreal)));
646- connect(newTab, SIGNAL(rotationChanged(Rotation)), SLOT(on_currentTab_rotationChanged(Rotation)));
647-
648- connect(newTab, SIGNAL(linkClicked(int)), SLOT(on_currentTab_linkClicked(int)));
649- connect(newTab, SIGNAL(linkClicked(bool,QString,int)), SLOT(on_currentTab_linkClicked(bool,QString,int)));
650-
651- connect(newTab, SIGNAL(renderFlagsChanged(qpdfview::RenderFlags)), SLOT(on_currentTab_renderFlagsChanged(qpdfview::RenderFlags)));
652-
653- connect(newTab, SIGNAL(invertColorsChanged(bool)), SLOT(on_currentTab_invertColorsChanged(bool)));
654- connect(newTab, SIGNAL(convertToGrayscaleChanged(bool)), SLOT(on_currentTab_convertToGrayscaleChanged(bool)));
655- connect(newTab, SIGNAL(trimMarginsChanged(bool)), SLOT(on_currentTab_trimMarginsChanged(bool)));
656-
657- connect(newTab, SIGNAL(compositionModeChanged(CompositionMode)), SLOT(on_currentTab_compositionModeChanged(CompositionMode)));
658-
659- connect(newTab, SIGNAL(highlightAllChanged(bool)), SLOT(on_currentTab_highlightAllChanged(bool)));
660- connect(newTab, SIGNAL(rubberBandModeChanged(RubberBandMode)), SLOT(on_currentTab_rubberBandModeChanged(RubberBandMode)));
661-
662- connect(newTab, SIGNAL(searchFinished()), SLOT(on_currentTab_searchFinished()));
663- connect(newTab, SIGNAL(searchProgressChanged(int)), SLOT(on_currentTab_searchProgressChanged(int)));
664-
665- connect(newTab, SIGNAL(customContextMenuRequested(QPoint)), SLOT(on_currentTab_customContextMenuRequested(QPoint)));
666+ addTab(newTab);
667+ addTabAction(newTab);
668+ connectTab(newTab);
669
670 newTab->show();
671
672@@ -508,27 +525,30 @@
673
674 for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
675 {
676- if(tab(index)->fileInfo() == fileInfo)
677+ foreach(DocumentView* tab, allTabs(index))
678 {
679- m_tabWidget->setCurrentIndex(index);
680-
681- if(refreshBeforeJump)
682- {
683- if(!currentTab()->refresh())
684- {
685- return false;
686- }
687- }
688-
689- currentTab()->jumpToPage(page);
690- currentTab()->setFocus();
691-
692- if(!highlight.isNull())
693- {
694- currentTab()->temporaryHighlight(page, highlight);
695- }
696-
697- return true;
698+ if(tab->fileInfo() == fileInfo)
699+ {
700+ m_tabWidget->setCurrentIndex(index);
701+
702+ if(refreshBeforeJump)
703+ {
704+ if(!tab->refresh())
705+ {
706+ return false;
707+ }
708+ }
709+
710+ tab->jumpToPage(page);
711+ tab->setFocus();
712+
713+ if(!highlight.isNull())
714+ {
715+ tab->temporaryHighlight(page, highlight);
716+ }
717+
718+ return true;
719+ }
720 }
721 }
722
723@@ -537,14 +557,14 @@
724
725 void MainWindow::startSearch(const QString& text)
726 {
727- if(m_tabWidget->currentIndex() != -1)
728+ if(DocumentView* const tab = currentTab())
729 {
730 m_searchDock->setVisible(true);
731
732 m_searchLineEdit->setText(text);
733 m_searchLineEdit->startSearch();
734
735- currentTab()->setFocus();
736+ tab->setFocus();
737 }
738 }
739
740@@ -555,11 +575,13 @@
741
742 void MainWindow::on_tabWidget_currentChanged(int index)
743 {
744+ if(m_currentTabChangedBlocked)
745+ {
746+ return;
747+ }
748+
749 const bool hasCurrent = index != -1;
750
751- m_openCopyInNewTabAction->setEnabled(hasCurrent);
752- m_openContainingFolderAction->setEnabled(hasCurrent);
753- m_moveToInstanceAction->setEnabled(hasCurrent);
754 m_refreshAction->setEnabled(hasCurrent);
755 m_printAction->setEnabled(hasCurrent);
756
757@@ -622,6 +644,13 @@
758 m_wholeWordsCheckBox->setEnabled(hasCurrent);
759 m_highlightAllCheckBox->setEnabled(hasCurrent);
760
761+ m_openCopyInNewTabAction->setEnabled(hasCurrent);
762+ m_openContainingFolderAction->setEnabled(hasCurrent);
763+ m_moveToInstanceAction->setEnabled(hasCurrent);
764+ m_splitViewHorizontallyAction->setEnabled(hasCurrent);
765+ m_splitViewVerticallyAction->setEnabled(hasCurrent);
766+ m_closeCurrentViewAction->setEnabled(hasCurrent);
767+
768 m_searchDock->toggleViewAction()->setEnabled(hasCurrent);
769
770 if(hasCurrent)
771@@ -639,6 +668,8 @@
772
773 m_bookmarksView->setModel(bookmarkModelForCurrentTab());
774
775+ on_thumbnails_dockLocationChanged(dockWidgetArea(m_thumbnailsDock));
776+
777 m_thumbnailsView->setScene(currentTab()->thumbnailsScene());
778 currentTab()->setThumbnailsViewportSize(m_thumbnailsView->viewport()->size());
779
780@@ -715,23 +746,20 @@
781
782 void MainWindow::on_tabWidget_tabCloseRequested(int index)
783 {
784- if(saveModifications(tab(index)))
785- {
786- closeTab(tab(index));
787- }
788+ on_closeTabs_triggered(allTabs(index));
789 }
790
791 void MainWindow::on_tabWidget_tabDragRequested(int index)
792 {
793 QMimeData* mimeData = new QMimeData();
794- mimeData->setUrls(QList< QUrl >() << QUrl::fromLocalFile(tab(index)->fileInfo().absoluteFilePath()));
795+ mimeData->setUrls(QList< QUrl >() << QUrl::fromLocalFile(currentTab(index)->fileInfo().absoluteFilePath()));
796
797 QDrag* drag = new QDrag(this);
798 drag->setMimeData(mimeData);
799 drag->exec();
800 }
801
802-void MainWindow::on_tabWidget_tabContextMenuRequested(const QPoint& globalPos, int index)
803+void MainWindow::on_tabWidget_tabContextMenuRequested(QPoint globalPos, int index)
804 {
805 QMenu menu;
806
807@@ -739,6 +767,9 @@
808 SignalBlocker openCopyInNewTabSignalBlocker(m_openCopyInNewTabAction);
809 SignalBlocker openContainingFolderSignalBlocker(m_openContainingFolderAction);
810 SignalBlocker moveToInstanceSignalBlocker(m_moveToInstanceAction);
811+ SignalBlocker splitViewHorizontallySignalBlocker(m_splitViewHorizontallyAction);
812+ SignalBlocker splitViewVerticallySignalBlocker(m_splitViewVerticallyAction);
813+ SignalBlocker closeCurrentViewSignalBlocker(m_closeCurrentViewAction);
814
815 QAction* copyFilePathAction = createTemporaryAction(&menu, tr("Copy file path"), QLatin1String("copyFilePath"));
816 QAction* selectFilePathAction = createTemporaryAction(&menu, tr("Select file path"), QLatin1String("selectFilePath"));
817@@ -753,6 +784,7 @@
818 QList< QAction* > actions;
819
820 actions << m_openCopyInNewTabAction << m_openContainingFolderAction << m_moveToInstanceAction
821+ << m_splitViewHorizontallyAction << m_splitViewVerticallyAction << m_closeCurrentViewAction
822 << copyFilePathAction << selectFilePathAction
823 << closeAllTabsAction << closeAllTabsButThisOneAction
824 << closeAllTabsToTheLeftAction << closeAllTabsToTheRightAction;
825@@ -761,104 +793,80 @@
826
827 const QAction* action = menu.exec(globalPos);
828
829- DocumentView* selectedTab = tab(index);
830- QList< DocumentView* > tabsToClose;
831+ DocumentView* const tab = currentTab(index);
832
833 if(action == m_openCopyInNewTabAction)
834 {
835- on_openCopyInNewTab_triggered(selectedTab);
836- return;
837+ on_openCopyInNewTab_triggered(tab);
838 }
839 else if(action == m_openContainingFolderAction)
840 {
841- on_openContainingFolder_triggered(selectedTab);
842- return;
843+ on_openContainingFolder_triggered(tab);
844 }
845 else if(action == m_moveToInstanceAction)
846 {
847- on_moveToInstance_triggered(selectedTab);
848- return;
849+ on_moveToInstance_triggered(tab);
850+ }
851+ else if(action == m_splitViewHorizontallyAction)
852+ {
853+ on_splitView_split_triggered(Qt::Horizontal, index);
854+ }
855+ else if(action == m_splitViewVerticallyAction)
856+ {
857+ on_splitView_split_triggered(Qt::Vertical, index);
858+ }
859+ else if(action == m_closeCurrentViewAction)
860+ {
861+ on_splitView_closeCurrent_triggered(index);
862 }
863 else if(action == copyFilePathAction)
864 {
865- QApplication::clipboard()->setText(selectedTab->fileInfo().absoluteFilePath());
866- return;
867+ QApplication::clipboard()->setText(tab->fileInfo().absoluteFilePath());
868 }
869 else if(action == selectFilePathAction)
870 {
871- QApplication::clipboard()->setText(selectedTab->fileInfo().absoluteFilePath(), QClipboard::Selection);
872- return;
873+ QApplication::clipboard()->setText(tab->fileInfo().absoluteFilePath(), QClipboard::Selection);
874 }
875 else if(action == closeAllTabsAction)
876 {
877- tabsToClose = tabs();
878+ on_closeAllTabs_triggered();
879 }
880 else if(action == closeAllTabsButThisOneAction)
881 {
882- const int count = m_tabWidget->count();
883-
884- for(int indexToClose = 0; indexToClose < count; ++indexToClose)
885- {
886- if(indexToClose != index)
887- {
888- tabsToClose.append(tab(indexToClose));
889- }
890- }
891+ on_closeAllTabsButThisOne_triggered(index);
892 }
893 else if(action == closeAllTabsToTheLeftAction)
894 {
895- for(int indexToClose = 0; indexToClose < index; ++indexToClose)
896- {
897- tabsToClose.append(tab(indexToClose));
898- }
899+ on_closeAllTabsToTheLeft_triggered(index);
900 }
901 else if(action == closeAllTabsToTheRightAction)
902 {
903- const int count = m_tabWidget->count();
904-
905- for(int indexToClose = count - 1; indexToClose > index; --indexToClose)
906- {
907- tabsToClose.append(tab(indexToClose));
908- }
909- }
910- else
911- {
912- return;
913- }
914-
915- disconnectCurrentTabChanged();
916-
917- foreach(DocumentView* tab, tabsToClose)
918- {
919- if(saveModifications(tab))
920- {
921- closeTab(tab);
922- }
923- }
924-
925- reconnectCurrentTabChanged();
926+ on_closeAllTabsToTheRight_triggered(index);
927+ }
928 }
929
930 #define ONLY_IF_SENDER_IS_CURRENT_TAB if(!senderIsCurrentTab()) { return; }
931
932 void MainWindow::on_currentTab_documentChanged()
933 {
934+ DocumentView* const senderTab = findCurrentTab(sender());
935+
936 for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
937 {
938- if(sender() == m_tabWidget->widget(index))
939- {
940- m_tabWidget->setTabText(index, tab(index)->title());
941- m_tabWidget->setTabToolTip(index, tab(index)->fileInfo().absoluteFilePath());
942-
943- foreach(QAction* tabAction, m_tabsMenu->actions())
944- {
945- if(tabAction->parent() == m_tabWidget->widget(index))
946- {
947- tabAction->setText(m_tabWidget->tabText(index));
948-
949- break;
950- }
951- }
952+ if(senderTab == currentTab(index))
953+ {
954+ m_tabWidget->setTabText(index, senderTab->title());
955+ m_tabWidget->setTabToolTip(index, senderTab->fileInfo().absoluteFilePath());
956+
957+ break;
958+ }
959+ }
960+
961+ foreach(QAction* tabAction, m_tabsMenu->actions())
962+ {
963+ if(senderTab == tabAction->parent())
964+ {
965+ tabAction->setText(senderTab->title());
966
967 break;
968 }
969@@ -1119,7 +1127,7 @@
970 m_searchLineEdit->setProgress(progress);
971 }
972
973-void MainWindow::on_currentTab_customContextMenuRequested(const QPoint& pos)
974+void MainWindow::on_currentTab_customContextMenuRequested(QPoint pos)
975 {
976 ONLY_IF_SENDER_IS_CURRENT_TAB
977
978@@ -1130,6 +1138,7 @@
979 QList< QAction* > actions;
980
981 actions << m_openCopyInNewTabAction << m_openContainingFolderAction << m_moveToInstanceAction
982+ << m_splitViewHorizontallyAction << m_splitViewVerticallyAction << m_closeCurrentViewAction
983 << m_previousPageAction << m_nextPageAction
984 << m_firstPageAction << m_lastPageAction
985 << m_jumpToPageAction << m_jumpBackwardAction << m_jumpForwardAction
986@@ -1153,11 +1162,102 @@
987 }
988 }
989
990+void MainWindow::on_splitView_splitHorizontally_triggered()
991+{
992+ on_splitView_split_triggered(Qt::Horizontal, m_tabWidget->currentIndex());
993+}
994+
995+void MainWindow::on_splitView_splitVertically_triggered()
996+{
997+ on_splitView_split_triggered(Qt::Vertical, m_tabWidget->currentIndex());
998+}
999+
1000+void MainWindow::on_splitView_split_triggered(Qt::Orientation orientation, int index)
1001+{
1002+ const QString path = s_settings->mainWindow().openPath();
1003+ const QString filePath = QFileDialog::getOpenFileName(this, tr("Open"), path, DocumentView::openFilter().join(";;"));
1004+
1005+ if(filePath.isEmpty())
1006+ {
1007+ return;
1008+ }
1009+
1010+ DocumentView* const newTab = new DocumentView(this);
1011+
1012+ if(!newTab->open(filePath))
1013+ {
1014+ delete newTab;
1015+ return;
1016+ }
1017+
1018+ Splitter* splitter = new Splitter(orientation, this);
1019+ connect(splitter, SIGNAL(currentWidgetChanged(QWidget*)), this, SLOT(on_splitView_currentWidgetChanged(QWidget*)));
1020+
1021+ QWidget* const tab = m_tabWidget->widget(index);
1022+ const QString tabText = m_tabWidget->tabText(index);
1023+ const QString tabToolTip = m_tabWidget->tabToolTip(index);
1024+
1025+ m_tabWidget->removeTab(index);
1026+
1027+ splitter->addWidget(tab);
1028+ splitter->addWidget(newTab);
1029+
1030+ m_tabWidget->insertTab(index, splitter, tabText);
1031+ m_tabWidget->setTabToolTip(index, tabToolTip);
1032+
1033+ addTabAction(newTab);
1034+ connectTab(newTab);
1035+
1036+ m_tabWidget->setCurrentIndex(index);
1037+ tab->setFocus();
1038+
1039+ splitter->setUniformSizes();
1040+ tab->show();
1041+ newTab->show();
1042+
1043+ if(s_settings->mainWindow().synchronizeSplitViews())
1044+ {
1045+ DocumentView* const oldTab = findCurrentTab(tab);
1046+
1047+ connect(oldTab, SIGNAL(currentPageChanged(int,bool)), newTab, SLOT(jumpToPage(int,bool)));
1048+ connect(oldTab->horizontalScrollBar(), SIGNAL(valueChanged(int)), newTab->horizontalScrollBar(), SLOT(setValue(int)));
1049+ connect(oldTab->verticalScrollBar(), SIGNAL(valueChanged(int)), newTab->verticalScrollBar(), SLOT(setValue(int)));
1050+ }
1051+}
1052+
1053+void MainWindow::on_splitView_closeCurrent_triggered()
1054+{
1055+ on_splitView_closeCurrent_triggered(m_tabWidget->currentIndex());
1056+}
1057+
1058+void MainWindow::on_splitView_closeCurrent_triggered(int index)
1059+{
1060+ DocumentView* const tab = currentTab(index);
1061+
1062+ if(saveModifications(tab))
1063+ {
1064+ closeTab(tab);
1065+ }
1066+}
1067+
1068+void MainWindow::on_splitView_currentWidgetChanged(QWidget* currentWidget)
1069+{
1070+ for(QWidget* parentWidget = currentWidget->parentWidget(); parentWidget != 0; parentWidget = parentWidget->parentWidget())
1071+ {
1072+ if(parentWidget == m_tabWidget->currentWidget())
1073+ {
1074+ on_tabWidget_currentChanged(m_tabWidget->currentIndex());
1075+
1076+ return;
1077+ }
1078+ }
1079+}
1080+
1081 #undef ONLY_IF_SENDER_IS_CURRENT_TAB
1082
1083 void MainWindow::on_currentPage_editingFinished()
1084 {
1085- if(m_tabWidget->currentIndex() != -1)
1086+ if(m_tabWidget->hasCurrent())
1087 {
1088 currentTab()->jumpToPage(m_currentPageSpinBox->value());
1089 }
1090@@ -1195,7 +1295,7 @@
1091
1092 void MainWindow::on_scaleFactor_editingFinished()
1093 {
1094- if(m_tabWidget->currentIndex() != -1)
1095+ if(m_tabWidget->hasCurrent())
1096 {
1097 bool ok = false;
1098 qreal scaleFactor = m_scaleFactorComboBox->lineEdit()->text().toInt(&ok) / 100.0;
1099@@ -1221,7 +1321,7 @@
1100
1101 void MainWindow::on_open_triggered()
1102 {
1103- if(m_tabWidget->currentIndex() != -1)
1104+ if(m_tabWidget->hasCurrent())
1105 {
1106 const QString path = s_settings->mainWindow().openPath();
1107 const QString filePath = QFileDialog::getOpenFileName(this, tr("Open"), path, DocumentView::openFilter().join(";;"));
1108@@ -1244,14 +1344,12 @@
1109
1110 if(!filePaths.isEmpty())
1111 {
1112- disconnectCurrentTabChanged();
1113+ CurrentTabChangeBlocker currentTabChangeBlocker(this);
1114
1115 foreach(const QString& filePath, filePaths)
1116 {
1117 openInNewTab(filePath);
1118 }
1119-
1120- reconnectCurrentTabChanged();
1121 }
1122 }
1123
1124@@ -1517,9 +1615,9 @@
1125 m_searchLineEdit->stopTimer();
1126 m_searchLineEdit->setProgress(0);
1127
1128- for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1129+ foreach(DocumentView* tab, allTabs())
1130 {
1131- tab(index)->cancelSearch();
1132+ tab->cancelSearch();
1133 }
1134
1135 if(!s_settings->mainWindow().extendedSearchDock())
1136@@ -1558,9 +1656,9 @@
1137
1138 m_saveDatabaseTimer->setInterval(s_settings->mainWindow().saveDatabaseInterval());
1139
1140- for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1141+ foreach(DocumentView* tab, allTabs())
1142 {
1143- if(!tab(index)->refresh())
1144+ if(!tab->refresh())
1145 {
1146 QMessageBox::warning(this, tr("Warning"), tr("Could not refresh '%1'.").arg(currentTab()->fileInfo().filePath()));
1147 }
1148@@ -1691,76 +1789,79 @@
1149
1150 void MainWindow::on_previousTab_triggered()
1151 {
1152- if(m_tabWidget->currentIndex() > 0)
1153- {
1154- m_tabWidget->setCurrentIndex(m_tabWidget->currentIndex() - 1);
1155- }
1156- else
1157- {
1158- m_tabWidget->setCurrentIndex(m_tabWidget->count() - 1);
1159- }
1160+ m_tabWidget->previousTab();
1161 }
1162
1163 void MainWindow::on_nextTab_triggered()
1164 {
1165- if(m_tabWidget->currentIndex() < m_tabWidget->count() - 1)
1166- {
1167- m_tabWidget->setCurrentIndex(m_tabWidget->currentIndex() + 1);
1168- }
1169- else
1170- {
1171- m_tabWidget->setCurrentIndex(0);
1172- }
1173+ m_tabWidget->nextTab();
1174 }
1175
1176 void MainWindow::on_closeTab_triggered()
1177 {
1178- if(saveModifications(currentTab()))
1179- {
1180- closeTab(currentTab());
1181- }
1182+ on_closeTabs_triggered(allTabs(m_tabWidget->currentIndex()));
1183 }
1184
1185 void MainWindow::on_closeAllTabs_triggered()
1186 {
1187- disconnectCurrentTabChanged();
1188-
1189- foreach(DocumentView* tab, tabs())
1190- {
1191- if(saveModifications(tab))
1192- {
1193- closeTab(tab);
1194- }
1195- }
1196-
1197- reconnectCurrentTabChanged();
1198+ on_closeTabs_triggered(allTabs());
1199 }
1200
1201 void MainWindow::on_closeAllTabsButCurrentTab_triggered()
1202 {
1203- disconnectCurrentTabChanged();
1204-
1205- DocumentView* tab = currentTab();
1206-
1207- const int oldIndex = m_tabWidget->currentIndex();
1208- const QString tabText = m_tabWidget->tabText(oldIndex);
1209- const QString tabToolTip = m_tabWidget->tabToolTip(oldIndex);
1210-
1211- m_tabWidget->removeTab(oldIndex);
1212-
1213- foreach(DocumentView* tab, tabs())
1214+ on_closeAllTabsButThisOne_triggered(m_tabWidget->currentIndex());
1215+}
1216+
1217+void MainWindow::on_closeAllTabsButThisOne_triggered(int thisIndex)
1218+{
1219+ QVector< DocumentView* > tabs;
1220+
1221+ for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1222+ {
1223+ if(index != thisIndex)
1224+ {
1225+ tabs.append(allTabs(index));
1226+ }
1227+ }
1228+
1229+ on_closeTabs_triggered(tabs);
1230+}
1231+
1232+void MainWindow::on_closeAllTabsToTheLeft_triggered(int ofIndex)
1233+{
1234+ QVector< DocumentView* > tabs;
1235+
1236+ for(int index = 0; index < ofIndex; ++index)
1237+ {
1238+ tabs.append(allTabs(index));
1239+ }
1240+
1241+ on_closeTabs_triggered(tabs);
1242+}
1243+
1244+void MainWindow::on_closeAllTabsToTheRight_triggered(int ofIndex)
1245+{
1246+ QVector< DocumentView* > tabs;
1247+
1248+ for(int index = ofIndex + 1, count = m_tabWidget->count(); index < count; ++index)
1249+ {
1250+ tabs.append(allTabs(index));
1251+ }
1252+
1253+ on_closeTabs_triggered(tabs);
1254+}
1255+
1256+void MainWindow::on_closeTabs_triggered(const QVector< DocumentView* >& tabs)
1257+{
1258+ CurrentTabChangeBlocker currentTabChangeBlocker(this);
1259+
1260+ foreach(DocumentView* tab, tabs)
1261 {
1262 if(saveModifications(tab))
1263 {
1264 closeTab(tab);
1265 }
1266 }
1267-
1268- const int newIndex = m_tabWidget->addTab(tab, tabText);
1269- m_tabWidget->setTabToolTip(newIndex, tabToolTip);
1270- m_tabWidget->setCurrentIndex(newIndex);
1271-
1272- reconnectCurrentTabChanged();
1273 }
1274
1275 void MainWindow::on_restoreMostRecentlyClosedTab_triggered()
1276@@ -1781,11 +1882,14 @@
1277
1278 void MainWindow::on_tabAction_triggered()
1279 {
1280+ DocumentView* const senderTab = static_cast< DocumentView* >(sender()->parent());
1281+
1282 for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1283 {
1284- if(sender()->parent() == m_tabWidget->widget(index))
1285+ if(allTabs(index).contains(senderTab))
1286 {
1287 m_tabWidget->setCurrentIndex(index);
1288+ senderTab->setFocus();
1289
1290 break;
1291 }
1292@@ -1967,7 +2071,7 @@
1293
1294 void MainWindow::on_bookmark_openTriggered(const QString& absoluteFilePath)
1295 {
1296- if(m_tabWidget->currentIndex() != -1)
1297+ if(m_tabWidget->hasCurrent())
1298 {
1299 open(absoluteFilePath);
1300 }
1301@@ -2092,15 +2196,15 @@
1302 return;
1303 }
1304
1305- const bool allTabs = s_settings->mainWindow().extendedSearchDock() ? !modified : modified;
1306+ const bool forAllTabs = s_settings->mainWindow().extendedSearchDock() ? !modified : modified;
1307 const bool matchCase = m_matchCaseCheckBox->isChecked();
1308 const bool wholeWords = m_wholeWordsCheckBox->isChecked();
1309
1310- if(allTabs)
1311+ if(forAllTabs)
1312 {
1313- for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1314+ foreach(DocumentView* tab, allTabs())
1315 {
1316- tab(index)->startSearch(text, matchCase, wholeWords);
1317+ tab->startSearch(text, matchCase, wholeWords);
1318 }
1319 }
1320 else
1321@@ -2194,9 +2298,9 @@
1322
1323 void MainWindow::on_thumbnails_dockLocationChanged(Qt::DockWidgetArea area)
1324 {
1325- for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1326+ foreach(DocumentView* tab, allTabs())
1327 {
1328- tab(index)->setThumbnailsOrientation(area == Qt::TopDockWidgetArea || area == Qt::BottomDockWidgetArea ? Qt::Horizontal : Qt::Vertical);
1329+ tab->setThumbnailsOrientation(area == Qt::TopDockWidgetArea || area == Qt::BottomDockWidgetArea ? Qt::Horizontal : Qt::Vertical);
1330 }
1331 }
1332
1333@@ -2243,7 +2347,7 @@
1334 }
1335 }
1336
1337-void MainWindow::on_bookmarks_contextMenuRequested(const QPoint& pos)
1338+void MainWindow::on_bookmarks_contextMenuRequested(QPoint pos)
1339 {
1340 QMenu menu;
1341
1342@@ -2363,26 +2467,38 @@
1343 m_searchLineEdit->stopTimer();
1344 m_searchLineEdit->setProgress(0);
1345
1346- for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1347+ foreach(DocumentView* tab, allTabs())
1348 {
1349- tab(index)->cancelSearch();
1350- tab(index)->clearResults();
1351+ tab->cancelSearch();
1352+ tab->clearResults();
1353 }
1354
1355- if(m_tabWidget->currentWidget() != 0)
1356+ if(DocumentView* tab = currentTab())
1357 {
1358- m_tabWidget->currentWidget()->setFocus();
1359+ tab->setFocus();
1360 }
1361 }
1362 }
1363
1364-void MainWindow::on_search_clicked(const QModelIndex& index)
1365+void MainWindow::on_search_clicked(const QModelIndex& clickedIndex)
1366 {
1367- DocumentView* tab = SearchModel::instance()->viewForIndex(index);
1368-
1369- m_tabWidget->setCurrentWidget(tab);
1370-
1371- tab->findResult(index);
1372+ DocumentView* const clickedTab = SearchModel::instance()->viewForIndex(clickedIndex);
1373+
1374+ for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1375+ {
1376+ foreach(DocumentView* tab, allTabs(index))
1377+ {
1378+ if(tab == clickedTab)
1379+ {
1380+ m_tabWidget->setCurrentIndex(index);
1381+ tab->setFocus();
1382+
1383+ clickedTab->findResult(clickedIndex);
1384+
1385+ return;
1386+ }
1387+ }
1388+ }
1389 }
1390
1391 void MainWindow::on_search_rowsInserted(const QModelIndex& parent, int first, int last)
1392@@ -2407,7 +2523,7 @@
1393 {
1394 if(s_settings->mainWindow().restoreTabs())
1395 {
1396- s_database->saveTabs(tabs());
1397+ s_database->saveTabs(allTabs());
1398 }
1399
1400 if(s_settings->mainWindow().restoreBookmarks())
1401@@ -2417,7 +2533,7 @@
1402
1403 if(s_settings->mainWindow().restorePerFileSettings())
1404 {
1405- foreach(DocumentView* tab, tabs())
1406+ foreach(DocumentView* tab, allTabs())
1407 {
1408 s_database->savePerFileSettings(tab);
1409 }
1410@@ -2458,18 +2574,22 @@
1411
1412 for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1413 {
1414- if(!saveModifications(tab(index)))
1415+ foreach(DocumentView* tab, allTabs(index))
1416 {
1417- m_tabWidget->setCurrentIndex(index);
1418+ if(!saveModifications(tab))
1419+ {
1420+ m_tabWidget->setCurrentIndex(index);
1421+ tab->setFocus();
1422
1423- event->setAccepted(false);
1424- return;
1425+ event->setAccepted(false);
1426+ return;
1427+ }
1428 }
1429 }
1430
1431 if(s_settings->mainWindow().restoreTabs())
1432 {
1433- s_database->saveTabs(tabs());
1434+ s_database->saveTabs(allTabs());
1435 }
1436 else
1437 {
1438@@ -2510,7 +2630,7 @@
1439 {
1440 event->acceptProposedAction();
1441
1442- disconnectCurrentTabChanged();
1443+ CurrentTabChangeBlocker currentTabChangeBlocker(this);
1444
1445 foreach(const QUrl& url, event->mimeData()->urls())
1446 {
1447@@ -2523,8 +2643,6 @@
1448 openInNewTab(url.toLocalFile());
1449 }
1450 }
1451-
1452- reconnectCurrentTabChanged();
1453 }
1454 }
1455
1456@@ -2549,21 +2667,26 @@
1457
1458 inline DocumentView* MainWindow::currentTab() const
1459 {
1460- return qobject_cast< DocumentView* >(m_tabWidget->currentWidget());
1461-}
1462-
1463-inline DocumentView* MainWindow::tab(int index) const
1464-{
1465- return qobject_cast< DocumentView* >(m_tabWidget->widget(index));
1466-}
1467-
1468-QList< DocumentView* > MainWindow::tabs() const
1469-{
1470- QList< DocumentView* > tabs;
1471+ return findCurrentTab(m_tabWidget->currentWidget());
1472+}
1473+
1474+inline DocumentView* MainWindow::currentTab(int index) const
1475+{
1476+ return findCurrentTab(m_tabWidget->widget(index));
1477+}
1478+
1479+inline QVector< DocumentView* > MainWindow::allTabs(int index) const
1480+{
1481+ return findAllTabs(m_tabWidget->widget(index));
1482+}
1483+
1484+QVector< DocumentView* > MainWindow::allTabs() const
1485+{
1486+ QVector< DocumentView* > tabs;
1487
1488 for(int index = 0, count = m_tabWidget->count(); index < count; ++index)
1489 {
1490- tabs.append(tab(index));
1491+ tabs.append(allTabs(index));
1492 }
1493
1494 return tabs;
1495@@ -2571,50 +2694,61 @@
1496
1497 bool MainWindow::senderIsCurrentTab() const
1498 {
1499- return sender() == m_tabWidget->currentWidget() || qobject_cast< DocumentView* >(sender()) == 0;
1500-}
1501-
1502-int MainWindow::addTab(DocumentView* tab)
1503-{
1504- const int index = s_settings->mainWindow().newTabNextToCurrentTab() ?
1505- m_tabWidget->insertTab(m_tabWidget->currentIndex() + 1, tab, tab->title()) :
1506- m_tabWidget->addTab(tab, tab->title());
1507-
1508- m_tabWidget->setTabToolTip(index, tab->fileInfo().absoluteFilePath());
1509- m_tabWidget->setCurrentIndex(index);
1510-
1511- return index;
1512-}
1513-
1514-void MainWindow::closeTab(DocumentView* tab)
1515-{
1516- if(s_settings->mainWindow().keepRecentlyClosed())
1517- {
1518- foreach(QAction* tabAction, m_tabsMenu->actions())
1519- {
1520- if(tabAction->parent() == tab)
1521- {
1522- m_tabsMenu->removeAction(tabAction);
1523- m_tabWidget->removeTab(m_tabWidget->indexOf(tab));
1524-
1525- tab->setParent(this);
1526- tab->setVisible(false);
1527-
1528- m_recentlyClosedMenu->addTabAction(tabAction);
1529-
1530- break;
1531- }
1532- }
1533- }
1534- else
1535- {
1536- delete tab;
1537- }
1538-
1539- if(s_settings->mainWindow().exitAfterLastTab() && m_tabWidget->count() == 0)
1540- {
1541- close();
1542- }
1543+ return sender() == currentTab() || qobject_cast< DocumentView* >(sender()) == 0;
1544+}
1545+
1546+void MainWindow::addTab(DocumentView* tab)
1547+{
1548+ m_tabWidget->addTab(tab, s_settings->mainWindow().newTabNextToCurrentTab(),
1549+ tab->title(), tab->fileInfo().absoluteFilePath());
1550+}
1551+
1552+void MainWindow::addTabAction(DocumentView* tab)
1553+{
1554+ QAction* tabAction = new QAction(tab->title(), tab);
1555+ tabAction->setToolTip(tab->fileInfo().absoluteFilePath());
1556+ tabAction->setData(true); // Flag action for search-as-you-type
1557+
1558+ connect(tabAction, SIGNAL(triggered()), SLOT(on_tabAction_triggered()));
1559+
1560+ m_tabsMenu->addAction(tabAction);
1561+}
1562+
1563+void MainWindow::connectTab(DocumentView* tab)
1564+{
1565+ connect(tab, SIGNAL(documentChanged()), SLOT(on_currentTab_documentChanged()));
1566+ connect(tab, SIGNAL(documentModified()), SLOT(on_currentTab_documentModified()));
1567+
1568+ connect(tab, SIGNAL(numberOfPagesChanged(int)), SLOT(on_currentTab_numberOfPagesChaned(int)));
1569+ connect(tab, SIGNAL(currentPageChanged(int)), SLOT(on_currentTab_currentPageChanged(int)));
1570+
1571+ connect(tab, SIGNAL(canJumpChanged(bool,bool)), SLOT(on_currentTab_canJumpChanged(bool,bool)));
1572+
1573+ connect(tab, SIGNAL(continuousModeChanged(bool)), SLOT(on_currentTab_continuousModeChanged(bool)));
1574+ connect(tab, SIGNAL(layoutModeChanged(LayoutMode)), SLOT(on_currentTab_layoutModeChanged(LayoutMode)));
1575+ connect(tab, SIGNAL(rightToLeftModeChanged(bool)), SLOT(on_currentTab_rightToLeftModeChanged(bool)));
1576+ connect(tab, SIGNAL(scaleModeChanged(ScaleMode)), SLOT(on_currentTab_scaleModeChanged(ScaleMode)));
1577+ connect(tab, SIGNAL(scaleFactorChanged(qreal)), SLOT(on_currentTab_scaleFactorChanged(qreal)));
1578+ connect(tab, SIGNAL(rotationChanged(Rotation)), SLOT(on_currentTab_rotationChanged(Rotation)));
1579+
1580+ connect(tab, SIGNAL(linkClicked(int)), SLOT(on_currentTab_linkClicked(int)));
1581+ connect(tab, SIGNAL(linkClicked(bool,QString,int)), SLOT(on_currentTab_linkClicked(bool,QString,int)));
1582+
1583+ connect(tab, SIGNAL(renderFlagsChanged(qpdfview::RenderFlags)), SLOT(on_currentTab_renderFlagsChanged(qpdfview::RenderFlags)));
1584+
1585+ connect(tab, SIGNAL(invertColorsChanged(bool)), SLOT(on_currentTab_invertColorsChanged(bool)));
1586+ connect(tab, SIGNAL(convertToGrayscaleChanged(bool)), SLOT(on_currentTab_convertToGrayscaleChanged(bool)));
1587+ connect(tab, SIGNAL(trimMarginsChanged(bool)), SLOT(on_currentTab_trimMarginsChanged(bool)));
1588+
1589+ connect(tab, SIGNAL(compositionModeChanged(CompositionMode)), SLOT(on_currentTab_compositionModeChanged(CompositionMode)));
1590+
1591+ connect(tab, SIGNAL(highlightAllChanged(bool)), SLOT(on_currentTab_highlightAllChanged(bool)));
1592+ connect(tab, SIGNAL(rubberBandModeChanged(RubberBandMode)), SLOT(on_currentTab_rubberBandModeChanged(RubberBandMode)));
1593+
1594+ connect(tab, SIGNAL(searchFinished()), SLOT(on_currentTab_searchFinished()));
1595+ connect(tab, SIGNAL(searchProgressChanged(int)), SLOT(on_currentTab_searchProgressChanged(int)));
1596+
1597+ connect(tab, SIGNAL(customContextMenuRequested(QPoint)), SLOT(on_currentTab_customContextMenuRequested(QPoint)));
1598 }
1599
1600 bool MainWindow::saveModifications(DocumentView* tab)
1601@@ -2653,16 +2787,51 @@
1602 return true;
1603 }
1604
1605-void MainWindow::disconnectCurrentTabChanged()
1606-{
1607- disconnect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(on_tabWidget_currentChanged(int)));
1608-}
1609-
1610-void MainWindow::reconnectCurrentTabChanged()
1611-{
1612- connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(on_tabWidget_currentChanged(int)));
1613-
1614- on_tabWidget_currentChanged(m_tabWidget->currentIndex());
1615+void MainWindow::closeTab(DocumentView* tab)
1616+{
1617+ const int tabIndex = m_tabWidget->indexOf(tab);
1618+
1619+ if(s_settings->mainWindow().keepRecentlyClosed() && tabIndex != -1)
1620+ {
1621+ foreach(QAction* tabAction, m_tabsMenu->actions())
1622+ {
1623+ if(tabAction->parent() == tab)
1624+ {
1625+ m_tabsMenu->removeAction(tabAction);
1626+ m_tabWidget->removeTab(tabIndex);
1627+
1628+ tab->setParent(this);
1629+ tab->setVisible(false);
1630+
1631+ m_recentlyClosedMenu->addTabAction(tabAction);
1632+
1633+ break;
1634+ }
1635+ }
1636+ }
1637+ else
1638+ {
1639+ Splitter* const splitter = qobject_cast< Splitter* >(tab->parentWidget());
1640+
1641+ delete tab;
1642+
1643+ if(splitter != 0)
1644+ {
1645+ if(splitter->count() > 0)
1646+ {
1647+ splitter->widget(0)->setFocus();
1648+ }
1649+ else
1650+ {
1651+ delete splitter;
1652+ }
1653+ }
1654+
1655+ if(s_settings->mainWindow().exitAfterLastTab() && m_tabWidget->count() == 0)
1656+ {
1657+ close();
1658+ }
1659+ }
1660 }
1661
1662 void MainWindow::setWindowTitleForCurrentTab()
1663@@ -2670,16 +2839,16 @@
1664 QString tabText;
1665 QString instanceText;
1666
1667- if(m_tabWidget->currentIndex() != -1)
1668+ if(DocumentView* tab = currentTab())
1669 {
1670 QString currentPage;
1671
1672 if(s_settings->mainWindow().currentPageInWindowTitle())
1673 {
1674- currentPage = QString(" (%1 / %2)").arg(currentTab()->currentPage()).arg(currentTab()->numberOfPages());
1675+ currentPage = QString(" (%1 / %2)").arg(tab->currentPage()).arg(tab->numberOfPages());
1676 }
1677
1678- tabText = m_tabWidget->tabText(m_tabWidget->currentIndex()) + currentPage + QLatin1String("[*] - ");
1679+ tabText = m_tabWidget->currentTabText() + currentPage + QLatin1String("[*] - ");
1680 }
1681
1682 const QString instanceName = qApp->objectName();
1683@@ -2696,19 +2865,19 @@
1684 {
1685 QString suffix;
1686
1687- if(m_tabWidget->currentIndex() != -1)
1688+ if(DocumentView* tab = currentTab())
1689 {
1690- const int currentPage = currentTab()->currentPage();
1691- const int numberOfPages = currentTab()->numberOfPages();
1692-
1693- const QString& defaultPageLabel = currentTab()->defaultPageLabelFromNumber(currentPage);
1694- const QString& pageLabel = currentTab()->pageLabelFromNumber(currentPage);
1695-
1696- const QString& lastDefaultPageLabel = currentTab()->defaultPageLabelFromNumber(numberOfPages);
1697-
1698- if((s_settings->mainWindow().usePageLabel() || currentTab()->hasFrontMatter()) && defaultPageLabel != pageLabel)
1699+ const int currentPage = tab->currentPage();
1700+ const int numberOfPages = tab->numberOfPages();
1701+
1702+ const QString& defaultPageLabel = tab->defaultPageLabelFromNumber(currentPage);
1703+ const QString& pageLabel = tab->pageLabelFromNumber(currentPage);
1704+
1705+ const QString& lastDefaultPageLabel = tab->defaultPageLabelFromNumber(numberOfPages);
1706+
1707+ if((s_settings->mainWindow().usePageLabel() || tab->hasFrontMatter()) && defaultPageLabel != pageLabel)
1708 {
1709- suffix = QString(" (%1 / %2)").arg(defaultPageLabel).arg(lastDefaultPageLabel);
1710+ suffix = QString(" (%1 / %2)").arg(defaultPageLabel, lastDefaultPageLabel);
1711 }
1712 else
1713 {
1714@@ -2728,7 +2897,7 @@
1715 return BookmarkModel::fromPath(currentTab()->fileInfo().absoluteFilePath(), create);
1716 }
1717
1718-QAction* MainWindow::sourceLinkActionForCurrentTab(QObject* parent, const QPoint& pos)
1719+QAction* MainWindow::sourceLinkActionForCurrentTab(QObject* parent, QPoint pos)
1720 {
1721 QAction* action = createTemporaryAction(parent, QString(), QLatin1String("openSourceLink"));
1722
1723@@ -2808,6 +2977,8 @@
1724
1725 setCentralWidget(m_tabWidget);
1726
1727+ m_currentTabChangedBlocked = false;
1728+
1729 connect(m_tabWidget, SIGNAL(currentChanged(int)), SLOT(on_tabWidget_currentChanged(int)));
1730 connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(on_tabWidget_tabCloseRequested(int)));
1731 connect(m_tabWidget, SIGNAL(tabDragRequested(int)), SLOT(on_tabWidget_tabDragRequested(int)));
1732@@ -2926,9 +3097,6 @@
1733
1734 m_openAction = createAction(tr("&Open..."), QLatin1String("open"), QLatin1String("document-open"), QKeySequence::Open, SLOT(on_open_triggered()));
1735 m_openInNewTabAction = createAction(tr("Open in new &tab..."), QLatin1String("openInNewTab"), QLatin1String("tab-new"), QKeySequence::AddTab, SLOT(on_openInNewTab_triggered()));
1736- m_openCopyInNewTabAction = createAction(tr("Open &copy in new tab"), QLatin1String("openCopyInNewTab"), QLatin1String("tab-new"), QKeySequence(), SLOT(on_openCopyInNewTab_triggered()));
1737- m_openContainingFolderAction = createAction(tr("Open containing &folder"), QLatin1String("openContainingFolder"), QLatin1String("folder"), QKeySequence(), SLOT(on_openContainingFolder_triggered()));
1738- m_moveToInstanceAction = createAction(tr("Move to &instance..."), QLatin1String("moveToInstance"), QIcon(), QKeySequence(), SLOT(on_moveToInstance_triggered()));
1739 m_refreshAction = createAction(tr("&Refresh"), QLatin1String("refresh"), QLatin1String("view-refresh"), QKeySequence::Refresh, SLOT(on_refresh_triggered()));
1740 m_saveAction = createAction(tr("&Save"), QLatin1String("save"), QLatin1String("document-save"), QKeySequence::Save, SLOT(on_save_triggered()));
1741 m_saveAsAction = createAction(tr("Save &as..."), QLatin1String("saveAs"), QLatin1String("document-save-as"), QKeySequence::SaveAs, SLOT(on_saveAs_triggered()));
1742@@ -3035,6 +3203,15 @@
1743 m_contentsAction = createAction(tr("&Contents"), QLatin1String("contents"), QIcon::fromTheme("help-contents"), QKeySequence::HelpContents, SLOT(on_contents_triggered()));
1744 m_aboutAction = createAction(tr("&About"), QString(), QIcon::fromTheme("help-about"), QKeySequence(), SLOT(on_about_triggered()));
1745
1746+ // context
1747+
1748+ m_openCopyInNewTabAction = createAction(tr("Open &copy in new tab"), QLatin1String("openCopyInNewTab"), QLatin1String("tab-new"), QKeySequence(), SLOT(on_openCopyInNewTab_triggered()));
1749+ m_openContainingFolderAction = createAction(tr("Open containing &folder"), QLatin1String("openContainingFolder"), QLatin1String("folder"), QKeySequence(), SLOT(on_openContainingFolder_triggered()));
1750+ m_moveToInstanceAction = createAction(tr("Move to &instance..."), QLatin1String("moveToInstance"), QIcon(), QKeySequence(), SLOT(on_moveToInstance_triggered()));
1751+ m_splitViewHorizontallyAction = createAction(tr("Split view horizontally..."), QLatin1String("splitViewHorizontally"), QIcon(), QKeySequence(), SLOT(on_splitView_splitHorizontally_triggered()));
1752+ m_splitViewVerticallyAction = createAction(tr("Split view vertically..."), QLatin1String("splitViewVertically"), QIcon(), QKeySequence(), SLOT(on_splitView_splitVertically_triggered()));
1753+ m_closeCurrentViewAction = createAction(tr("Close current view"), QLatin1String("closeCurrentView"), QIcon(), QKeySequence(), SLOT(on_splitView_closeCurrent_triggered()));
1754+
1755 // tool bars and menu bar
1756
1757 m_toggleToolBarsAction = createAction(tr("Toggle tool bars"), QLatin1String("toggleToolBars"), QIcon(), QKeySequence(Qt::SHIFT + Qt::ALT + Qt::Key_T), SLOT(on_toggleToolBars_triggered(bool)), true, true);
1758@@ -3609,7 +3786,7 @@
1759
1760 const QFileInfo fileInfo(absoluteFilePath);
1761
1762- foreach(DocumentView* tab, mainWindow()->tabs())
1763+ foreach(DocumentView* tab, mainWindow()->allTabs())
1764 {
1765 if(tab->fileInfo() == fileInfo)
1766 {
1767
1768=== modified file 'sources/mainwindow.h'
1769--- sources/mainwindow.h 2016-11-03 09:05:49 +0000
1770+++ sources/mainwindow.h 2017-04-19 21:02:47 +0000
1771@@ -1,7 +1,7 @@
1772 /*
1773
1774 Copyright 2014 S. Razi Alavizadeh
1775-Copyright 2012-2015 Adam Reichold
1776+Copyright 2012-2017 Adam Reichold
1777 Copyright 2012 MichaƂ Trybus
1778 Copyright 2012 Alexander Volkov
1779
1780@@ -97,7 +97,7 @@
1781 void on_tabWidget_currentChanged(int index);
1782 void on_tabWidget_tabCloseRequested(int index);
1783 void on_tabWidget_tabDragRequested(int index);
1784- void on_tabWidget_tabContextMenuRequested(const QPoint& globalPos, int index);
1785+ void on_tabWidget_tabContextMenuRequested(QPoint globalPos, int index);
1786
1787 void on_currentTab_documentChanged();
1788 void on_currentTab_documentModified();
1789@@ -131,7 +131,14 @@
1790 void on_currentTab_searchFinished();
1791 void on_currentTab_searchProgressChanged(int progress);
1792
1793- void on_currentTab_customContextMenuRequested(const QPoint& pos);
1794+ void on_currentTab_customContextMenuRequested(QPoint pos);
1795+
1796+ void on_splitView_splitHorizontally_triggered();
1797+ void on_splitView_splitVertically_triggered();
1798+ void on_splitView_split_triggered(Qt::Orientation orientation, int index);
1799+ void on_splitView_closeCurrent_triggered();
1800+ void on_splitView_closeCurrent_triggered(int index);
1801+ void on_splitView_currentWidgetChanged(QWidget* currentWidget);
1802
1803 void on_currentPage_editingFinished();
1804 void on_currentPage_returnPressed();
1805@@ -211,6 +218,10 @@
1806 void on_closeTab_triggered();
1807 void on_closeAllTabs_triggered();
1808 void on_closeAllTabsButCurrentTab_triggered();
1809+ void on_closeAllTabsButThisOne_triggered(int thisIndex);
1810+ void on_closeAllTabsToTheLeft_triggered(int ofIndex);
1811+ void on_closeAllTabsToTheRight_triggered(int ofIndex);
1812+ void on_closeTabs_triggered(const QVector< DocumentView* >& tabs);
1813
1814 void on_restoreMostRecentlyClosedTab_triggered();
1815
1816@@ -256,7 +267,7 @@
1817
1818 void on_bookmarks_sectionCountChanged();
1819 void on_bookmarks_clicked(const QModelIndex& index);
1820- void on_bookmarks_contextMenuRequested(const QPoint& pos);
1821+ void on_bookmarks_contextMenuRequested(QPoint pos);
1822
1823 void on_search_sectionCountChanged();
1824 void on_search_dockLocationChanged(Qt::DockWidgetArea area);
1825@@ -287,25 +298,29 @@
1826 TabWidget* m_tabWidget;
1827
1828 DocumentView* currentTab() const;
1829- DocumentView* tab(int index) const;
1830- QList< DocumentView* > tabs() const;
1831+ DocumentView* currentTab(int index) const;
1832+ QVector< DocumentView* > allTabs(int index) const;
1833+ QVector< DocumentView* > allTabs() const;
1834
1835 bool senderIsCurrentTab() const;
1836
1837- int addTab(DocumentView* tab);
1838+ bool m_currentTabChangedBlocked;
1839+
1840+ class CurrentTabChangeBlocker;
1841+
1842+ void addTab(DocumentView* tab);
1843+ void addTabAction(DocumentView* tab);
1844+ void connectTab(DocumentView* tab);
1845+
1846+ bool saveModifications(DocumentView* tab);
1847 void closeTab(DocumentView* tab);
1848
1849- bool saveModifications(DocumentView* tab);
1850-
1851- void disconnectCurrentTabChanged();
1852- void reconnectCurrentTabChanged();
1853-
1854 void setWindowTitleForCurrentTab();
1855 void setCurrentPageSuffixForCurrentTab();
1856
1857 BookmarkModel* bookmarkModelForCurrentTab(bool create = false);
1858
1859- QAction* sourceLinkActionForCurrentTab(QObject* parent, const QPoint& pos);
1860+ QAction* sourceLinkActionForCurrentTab(QObject* parent, QPoint pos);
1861
1862 class RestoreTab;
1863
1864@@ -338,9 +353,6 @@
1865
1866 QAction* m_openAction;
1867 QAction* m_openInNewTabAction;
1868- QAction* m_openCopyInNewTabAction;
1869- QAction* m_openContainingFolderAction;
1870- QAction* m_moveToInstanceAction;
1871 QAction* m_refreshAction;
1872 QAction* m_saveAction;
1873 QAction* m_saveAsAction;
1874@@ -419,6 +431,13 @@
1875 QAction* m_contentsAction;
1876 QAction* m_aboutAction;
1877
1878+ QAction* m_openCopyInNewTabAction;
1879+ QAction* m_openContainingFolderAction;
1880+ QAction* m_moveToInstanceAction;
1881+ QAction* m_splitViewHorizontallyAction;
1882+ QAction* m_splitViewVerticallyAction;
1883+ QAction* m_closeCurrentViewAction;
1884+
1885 QAction* createAction(const QString& text, const QString& objectName, const QIcon& icon, const QList< QKeySequence >& shortcuts, const char* member, bool checkable = false, bool checked = false);
1886 QAction* createAction(const QString& text, const QString& objectName, const QIcon& icon, const QKeySequence& shortcut, const char* member, bool checkable = false, bool checked = false);
1887 QAction* createAction(const QString& text, const QString& objectName, const QString& iconName, const QList< QKeySequence >& shortcuts, const char* member, bool checkable = false, bool checked = false);
1888
1889=== modified file 'sources/miscellaneous.cpp'
1890--- sources/miscellaneous.cpp 2017-01-28 18:50:24 +0000
1891+++ sources/miscellaneous.cpp 2017-04-19 21:02:47 +0000
1892@@ -1,7 +1,7 @@
1893 /*
1894
1895 Copyright 2014 S. Razi Alavizadeh
1896-Copyright 2012-2015 Adam Reichold
1897+Copyright 2012-2017 Adam Reichold
1898 Copyright 2014 Dorian Scholz
1899
1900 This file is part of qpdfview.
1901@@ -304,6 +304,19 @@
1902 setTabBar(tabBar);
1903 }
1904
1905+int TabWidget::addTab(QWidget* const widget, const bool nextToCurrent,
1906+ const QString& label, const QString& toolTip)
1907+{
1908+ const int index = nextToCurrent
1909+ ? insertTab(currentIndex() + 1, widget, label)
1910+ : QTabWidget::addTab(widget, label);
1911+
1912+ setTabToolTip(index, toolTip);
1913+ setCurrentIndex(index);
1914+
1915+ return index;
1916+}
1917+
1918 TabWidget::TabBarPolicy TabWidget::tabBarPolicy() const
1919 {
1920 return m_tabBarPolicy;
1921@@ -343,7 +356,31 @@
1922 }
1923 }
1924
1925-void TabWidget::on_tabBar_customContextMenuRequested(const QPoint& pos)
1926+void TabWidget::previousTab()
1927+{
1928+ int index = currentIndex();
1929+
1930+ if(index < 0)
1931+ {
1932+ index = count() - 1;
1933+ }
1934+
1935+ setCurrentIndex(index);
1936+}
1937+
1938+void TabWidget::nextTab()
1939+{
1940+ int index = currentIndex();
1941+
1942+ if(index >= count())
1943+ {
1944+ index = 0;
1945+ }
1946+
1947+ setCurrentIndex(index);
1948+}
1949+
1950+void TabWidget::on_tabBar_customContextMenuRequested(QPoint pos)
1951 {
1952 const int index = tabBar()->tabAt(pos);
1953
1954@@ -865,11 +902,80 @@
1955 emit searchInitiated(text());
1956 }
1957
1958-void SearchLineEdit::on_returnPressed(const Qt::KeyboardModifiers& modifiers)
1959+void SearchLineEdit::on_returnPressed(Qt::KeyboardModifiers modifiers)
1960 {
1961 stopTimer();
1962
1963 emit searchInitiated(text(), modifiers == Qt::ShiftModifier);
1964 }
1965
1966+Splitter::Splitter(Qt::Orientation orientation, QWidget* parent) : QSplitter(orientation, parent),
1967+ m_currentIndex(0)
1968+{
1969+ connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), this, SLOT(on_focusChanged(QWidget*,QWidget*)));
1970+}
1971+
1972+QWidget* Splitter::currentWidget() const
1973+{
1974+ return widget(m_currentIndex);
1975+}
1976+
1977+void Splitter::setCurrentWidget(QWidget* const currentWidget)
1978+{
1979+ for(int index = 0, count = this->count(); index < count; ++index)
1980+ {
1981+ QWidget* const widget = this->widget(index);
1982+
1983+ if(currentWidget == widget)
1984+ {
1985+ if(m_currentIndex != index)
1986+ {
1987+ m_currentIndex = index;
1988+
1989+ emit currentWidgetChanged(currentWidget);
1990+ }
1991+
1992+ return;
1993+ }
1994+ }
1995+}
1996+
1997+void Splitter::setUniformSizes()
1998+{
1999+ int size;
2000+
2001+ switch(orientation())
2002+ {
2003+ default:
2004+ case Qt::Horizontal:
2005+ size = width();
2006+ break;
2007+ case Qt::Vertical:
2008+ size = height();
2009+ break;
2010+ }
2011+
2012+ QList< int > sizes;
2013+
2014+ for(int index = 0, count = this->count(); index < count; ++index)
2015+ {
2016+ sizes.append(size / count);
2017+ }
2018+
2019+ setSizes(sizes);
2020+}
2021+
2022+void Splitter::on_focusChanged(QWidget* /* old */, QWidget* now)
2023+{
2024+ for(QWidget* currentWidget = now; currentWidget != 0; currentWidget = currentWidget->parentWidget())
2025+ {
2026+ if(currentWidget->parentWidget() == this)
2027+ {
2028+ setCurrentWidget(currentWidget);
2029+
2030+ return;
2031+ }
2032+ }
2033+}
2034+
2035 } // qpdfview
2036
2037=== modified file 'sources/miscellaneous.h'
2038--- sources/miscellaneous.h 2017-01-26 15:18:35 +0000
2039+++ sources/miscellaneous.h 2017-04-19 21:02:47 +0000
2040@@ -1,7 +1,7 @@
2041 /*
2042
2043 Copyright 2014 S. Razi Alavizadeh
2044-Copyright 2012-2015 Adam Reichold
2045+Copyright 2012-2017 Adam Reichold
2046 Copyright 2014 Dorian Scholz
2047
2048 This file is part of qpdfview.
2049@@ -31,6 +31,7 @@
2050 #include <QPainter>
2051 #include <QProxyStyle>
2052 #include <QSpinBox>
2053+#include <QSplitter>
2054 #include <QTreeView>
2055
2056 class QTextLayout;
2057@@ -149,6 +150,17 @@
2058 public:
2059 explicit TabWidget(QWidget* parent = 0);
2060
2061+ bool hasCurrent() const { return currentIndex() != -1; }
2062+
2063+ QString currentTabText() const { return tabText(currentIndex()); }
2064+ void setCurrentTabText(const QString& text) { setTabText(currentIndex(), text); }
2065+
2066+ QString currentTabToolTip() const { return tabToolTip(currentIndex()); }
2067+ void setCurrentTabToolTip(const QString& toolTip) { setTabToolTip(currentIndex(), toolTip); }
2068+
2069+ int addTab(QWidget* const widget, const bool nextToCurrent,
2070+ const QString& label, const QString& toolTip);
2071+
2072 enum TabBarPolicy
2073 {
2074 TabBarAsNeeded = 0,
2075@@ -162,12 +174,16 @@
2076 bool spreadTabs() const;
2077 void setSpreadTabs(bool spreadTabs);
2078
2079+public slots:
2080+ void previousTab();
2081+ void nextTab();
2082+
2083 signals:
2084 void tabDragRequested(int index);
2085- void tabContextMenuRequested(const QPoint& globalPos, int index);
2086+ void tabContextMenuRequested(QPoint globalPos, int index);
2087
2088 protected slots:
2089- void on_tabBar_customContextMenuRequested(const QPoint& pos);
2090+ void on_tabBar_customContextMenuRequested(QPoint pos);
2091
2092 protected:
2093 void tabInserted(int index);
2094@@ -319,7 +335,7 @@
2095 void setProgress(int progress);
2096
2097 signals:
2098- void returnPressed(const Qt::KeyboardModifiers& modifiers);
2099+ void returnPressed(Qt::KeyboardModifiers modifiers);
2100
2101 protected:
2102 void paintEvent(QPaintEvent* event);
2103@@ -352,7 +368,7 @@
2104
2105 protected slots:
2106 void on_timeout();
2107- void on_returnPressed(const Qt::KeyboardModifiers& modifiers);
2108+ void on_returnPressed(Qt::KeyboardModifiers modifiers);
2109
2110 private:
2111 Q_DISABLE_COPY(SearchLineEdit)
2112@@ -361,6 +377,33 @@
2113
2114 };
2115
2116+// splitter
2117+
2118+class Splitter : public QSplitter
2119+{
2120+ Q_OBJECT
2121+
2122+public:
2123+ explicit Splitter(Qt::Orientation orientation, QWidget* parent = 0);
2124+
2125+ QWidget* currentWidget() const;
2126+ void setCurrentWidget(QWidget* const currentWidget);
2127+
2128+ void setUniformSizes();
2129+
2130+signals:
2131+ void currentWidgetChanged(QWidget* currentWidget);
2132+
2133+protected slots:
2134+ void on_focusChanged(QWidget* old, QWidget* now);
2135+
2136+private:
2137+ Q_DISABLE_COPY(Splitter)
2138+
2139+ int m_currentIndex;
2140+
2141+};
2142+
2143 // fallback icons
2144
2145 inline QIcon loadIconWithFallback(const QString& name)
2146
2147=== modified file 'sources/model.h'
2148--- sources/model.h 2017-04-02 09:36:22 +0000
2149+++ sources/model.h 2017-04-19 21:02:47 +0000
2150@@ -84,7 +84,7 @@
2151 Q_OBJECT
2152
2153 public:
2154- Annotation() : QObject() {}
2155+ Annotation(QObject* parent = 0) : QObject(parent) {}
2156 virtual ~Annotation() {}
2157
2158 virtual QRectF boundary() const = 0;
2159@@ -102,7 +102,7 @@
2160 Q_OBJECT
2161
2162 public:
2163- FormField() : QObject() {}
2164+ FormField(QObject* parent = 0) : QObject(parent) {}
2165 virtual ~FormField() {}
2166
2167 virtual QRectF boundary() const = 0;
2168@@ -122,7 +122,7 @@
2169
2170 virtual QSizeF size() const = 0;
2171
2172- virtual QImage render(qreal horizontalResolution = 72.0, qreal verticalResolution = 72.0, Rotation rotation = RotateBy0, const QRect& boundingRect = QRect()) const = 0;
2173+ virtual QImage render(qreal horizontalResolution = 72.0, qreal verticalResolution = 72.0, Rotation rotation = RotateBy0, QRect boundingRect = QRect()) const = 0;
2174
2175 virtual QString label() const { return QString(); }
2176
2177
2178=== modified file 'sources/pageitem.cpp'
2179--- sources/pageitem.cpp 2016-11-20 18:29:29 +0000
2180+++ sources/pageitem.cpp 2017-04-19 21:02:47 +0000
2181@@ -52,7 +52,7 @@
2182
2183 const qreal proxyPadding = 2.0;
2184
2185-inline bool modifiersAreActive(const QGraphicsSceneMouseEvent* event, const Qt::KeyboardModifiers& modifiers)
2186+inline bool modifiersAreActive(const QGraphicsSceneMouseEvent* event, Qt::KeyboardModifiers modifiers)
2187 {
2188 if(modifiers == Qt::NoModifier)
2189 {
2190@@ -770,7 +770,7 @@
2191 m_formFields = formFields;
2192 }
2193
2194-void PageItem::copyToClipboard(const QPoint& screenPos)
2195+void PageItem::copyToClipboard(QPoint screenPos)
2196 {
2197 QMenu menu;
2198
2199@@ -823,7 +823,7 @@
2200 }
2201 }
2202
2203-void PageItem::addAnnotation(const QPoint& screenPos)
2204+void PageItem::addAnnotation(QPoint screenPos)
2205 {
2206 if(m_page->canAddAndRemoveAnnotations())
2207 {
2208@@ -866,7 +866,7 @@
2209 }
2210 }
2211
2212-void PageItem::showLinkContextMenu(Model::Link* link, const QPoint& screenPos)
2213+void PageItem::showLinkContextMenu(Model::Link* link, QPoint screenPos)
2214 {
2215 if(link->page == -1)
2216 {
2217@@ -890,7 +890,7 @@
2218 }
2219 }
2220
2221-void PageItem::showAnnotationContextMenu(Model::Annotation* annotation, const QPoint& screenPos)
2222+void PageItem::showAnnotationContextMenu(Model::Annotation* annotation, QPoint screenPos)
2223 {
2224 if(m_page->canAddAndRemoveAnnotations())
2225 {
2226
2227=== modified file 'sources/pageitem.h'
2228--- sources/pageitem.h 2016-03-20 12:54:12 +0000
2229+++ sources/pageitem.h 2017-04-19 21:02:47 +0000
2230@@ -91,8 +91,8 @@
2231 const QTransform& transform() const { return m_transform; }
2232 const QTransform& normalizedTransform() const { return m_normalizedTransform; }
2233
2234- QPointF sourcePos(const QPointF& point) const { return m_transform.inverted().map(point); }
2235- QPointF normalizedSourcePos(const QPointF& point) const { return m_normalizedTransform.inverted().map(point); }
2236+ QPointF sourcePos(QPointF point) const { return m_transform.inverted().map(point); }
2237+ QPointF normalizedSourcePos(QPointF point) const { return m_normalizedTransform.inverted().map(point); }
2238
2239 signals:
2240 void cropRectChanged();
2241@@ -105,7 +105,7 @@
2242 void rubberBandFinished();
2243
2244 void zoomToSelection(int page, const QRectF& rect);
2245- void openInSourceEditor(int page, const QPointF& pos);
2246+ void openInSourceEditor(int page, QPointF pos);
2247
2248 void wasModified();
2249
2250@@ -174,11 +174,11 @@
2251 RubberBandMode m_rubberBandMode;
2252 QRectF m_rubberBand;
2253
2254- void copyToClipboard(const QPoint& screenPos);
2255- void addAnnotation(const QPoint& screenPos);
2256+ void copyToClipboard(QPoint screenPos);
2257+ void addAnnotation(QPoint screenPos);
2258
2259- void showLinkContextMenu(Model::Link* link, const QPoint& screenPos);
2260- void showAnnotationContextMenu(Model::Annotation* annotation, const QPoint& screenPos);
2261+ void showLinkContextMenu(Model::Link* link, QPoint screenPos);
2262+ void showAnnotationContextMenu(Model::Annotation* annotation, QPoint screenPos);
2263
2264 // overlay
2265
2266
2267=== modified file 'sources/pdfmodel.cpp'
2268--- sources/pdfmodel.cpp 2017-04-02 09:36:22 +0000
2269+++ sources/pdfmodel.cpp 2017-04-19 21:02:47 +0000
2270@@ -225,10 +225,46 @@
2271 typedef QSharedPointer< Poppler::TextBox > TextBox;
2272 typedef QList< TextBox > TextBoxList;
2273
2274-QCache< const PdfPage*, TextBoxList > textCache(1 << 12);
2275-QMutex textCacheMutex;
2276-
2277-#define LOCK_TEXT_CACHE QMutexLocker mutexLocker(&textCacheMutex);
2278+class TextCache
2279+{
2280+public:
2281+ TextCache() : m_mutex(), m_cache(1 << 12) {}
2282+
2283+ bool object(const PdfPage* page, TextBoxList& textBoxes) const
2284+ {
2285+ QMutexLocker mutexLocker(&m_mutex);
2286+
2287+ if(TextBoxList* const object = m_cache.object(page))
2288+ {
2289+ textBoxes = *object;
2290+
2291+ return true;
2292+ }
2293+
2294+ return false;
2295+ }
2296+
2297+ void insert(const PdfPage* page, const TextBoxList& textBoxes)
2298+ {
2299+ QMutexLocker mutexLocker(&m_mutex);
2300+
2301+ m_cache.insert(page, new TextBoxList(textBoxes), textBoxes.count());
2302+ }
2303+
2304+ void remove(const PdfPage* page)
2305+ {
2306+ QMutexLocker mutexLocker(&m_mutex);
2307+
2308+ m_cache.remove(page);
2309+ }
2310+
2311+private:
2312+ mutable QMutex m_mutex;
2313+ QCache< const PdfPage*, TextBoxList > m_cache;
2314+
2315+};
2316+
2317+Q_GLOBAL_STATIC(TextCache, textCache)
2318
2319 namespace Defaults
2320 {
2321@@ -403,11 +439,7 @@
2322
2323 PdfPage::~PdfPage()
2324 {
2325- {
2326- LOCK_TEXT_CACHE
2327-
2328- textCache.remove(this);
2329- }
2330+ textCache->remove(this);
2331
2332 delete m_page;
2333 }
2334@@ -419,7 +451,7 @@
2335 return m_page->pageSizeF();
2336 }
2337
2338-QImage PdfPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const
2339+QImage PdfPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const
2340 {
2341 LOCK_PAGE
2342
2343@@ -540,21 +572,9 @@
2344
2345 QString PdfPage::cachedText(const QRectF& rect) const
2346 {
2347- bool wasCached = false;
2348 TextBoxList textBoxes;
2349
2350- {
2351- LOCK_TEXT_CACHE
2352-
2353- if(const TextBoxList* object = textCache.object(this))
2354- {
2355- wasCached = true;
2356-
2357- textBoxes = *object;
2358- }
2359- }
2360-
2361- if(!wasCached)
2362+ if(!textCache->object(this, textBoxes))
2363 {
2364 {
2365 LOCK_PAGE
2366@@ -565,9 +585,7 @@
2367 }
2368 }
2369
2370- LOCK_TEXT_CACHE
2371-
2372- textCache.insert(this, new TextBoxList(textBoxes), textBoxes.count());
2373+ textCache->insert(this, textBoxes);
2374 }
2375
2376 QString text;
2377
2378=== modified file 'sources/pdfmodel.h'
2379--- sources/pdfmodel.h 2017-04-02 09:36:22 +0000
2380+++ sources/pdfmodel.h 2017-04-19 21:02:47 +0000
2381@@ -108,7 +108,7 @@
2382
2383 QSizeF size() const;
2384
2385- QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const;
2386+ QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const;
2387
2388 QString label() const;
2389
2390
2391=== modified file 'sources/psmodel.cpp'
2392--- sources/psmodel.cpp 2017-04-02 09:36:22 +0000
2393+++ sources/psmodel.cpp 2017-04-19 21:02:47 +0000
2394@@ -77,7 +77,7 @@
2395 return QSizeF(w, h);
2396 }
2397
2398-QImage PsPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const
2399+QImage PsPage::render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const
2400 {
2401 QMutexLocker mutexLocker(m_mutex);
2402
2403
2404=== modified file 'sources/psmodel.h'
2405--- sources/psmodel.h 2017-04-02 09:36:22 +0000
2406+++ sources/psmodel.h 2017-04-19 21:02:47 +0000
2407@@ -52,7 +52,7 @@
2408
2409 QSizeF size() const;
2410
2411- QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const;
2412+ QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const;
2413
2414 private:
2415 Q_DISABLE_COPY(PsPage)
2416
2417=== modified file 'sources/recentlyclosedmenu.cpp'
2418--- sources/recentlyclosedmenu.cpp 2017-01-26 15:18:35 +0000
2419+++ sources/recentlyclosedmenu.cpp 2017-04-19 21:02:47 +0000
2420@@ -44,7 +44,7 @@
2421 {
2422 if(m_tabActionGroup->actions().count() >= m_count)
2423 {
2424- QAction* first = m_tabActionGroup->actions().first();
2425+ QAction* first = m_tabActionGroup->actions().constFirst();
2426
2427 removeAction(first);
2428 m_tabActionGroup->removeAction(first);
2429@@ -52,7 +52,7 @@
2430 first->parent()->deleteLater();
2431 }
2432
2433- insertAction(actions().first(), tabAction);
2434+ insertAction(actions().constFirst(), tabAction);
2435 m_tabActionGroup->addAction(tabAction);
2436 }
2437
2438
2439=== modified file 'sources/recentlyusedmenu.cpp'
2440--- sources/recentlyusedmenu.cpp 2017-01-26 15:18:35 +0000
2441+++ sources/recentlyusedmenu.cpp 2017-04-19 21:02:47 +0000
2442@@ -56,7 +56,7 @@
2443 removeAction(action);
2444 m_openActionGroup->removeAction(action);
2445
2446- insertAction(actions().first(), action);
2447+ insertAction(actions().constFirst(), action);
2448 m_openActionGroup->addAction(action);
2449
2450 return;
2451@@ -65,7 +65,7 @@
2452
2453 if(m_openActionGroup->actions().count() >= m_count)
2454 {
2455- QAction* first = m_openActionGroup->actions().first();
2456+ QAction* first = m_openActionGroup->actions().constFirst();
2457
2458 removeAction(first);
2459 m_openActionGroup->removeAction(first);
2460@@ -77,7 +77,7 @@
2461 action->setToolTip(fileInfo.absoluteFilePath());
2462 action->setData(fileInfo.absoluteFilePath());
2463
2464- insertAction(actions().first(), action);
2465+ insertAction(actions().constFirst(), action);
2466 m_openActionGroup->addAction(action);
2467 }
2468
2469
2470=== modified file 'sources/searchmodel.cpp'
2471--- sources/searchmodel.cpp 2015-05-04 16:33:33 +0000
2472+++ sources/searchmodel.cpp 2017-04-19 21:02:47 +0000
2473@@ -323,15 +323,21 @@
2474
2475 void SearchModel::clearResults(DocumentView* view)
2476 {
2477- foreach(const TextCacheKey& key, m_textWatchers.keys())
2478+ typedef QHash< TextCacheKey, TextWatcher* >::iterator WatcherIterator;
2479+
2480+ for(WatcherIterator iterator = m_textWatchers.begin(); iterator != m_textWatchers.end(); ++iterator)
2481 {
2482+ const TextCacheKey& key = iterator.key();
2483+
2484 if(key.first == view)
2485 {
2486- TextWatcher* watcher = m_textWatchers.take(key);
2487-
2488+ TextWatcher* const watcher = iterator.value();
2489 watcher->cancel();
2490 watcher->waitForFinished();
2491 watcher->deleteLater();
2492+
2493+ iterator = m_textWatchers.erase(iterator);
2494+ continue;
2495 }
2496 }
2497
2498@@ -343,7 +349,7 @@
2499 }
2500 }
2501
2502- const QList< DocumentView* >::iterator at = qBinaryFind(m_views.begin(), m_views.end(), view);
2503+ const QVector< DocumentView* >::iterator at = qBinaryFind(m_views.begin(), m_views.end(), view);
2504 const int row = at - m_views.begin();
2505
2506 if(at == m_views.end())
2507@@ -408,7 +414,7 @@
2508
2509 QModelIndex SearchModel::findView(DocumentView *view) const
2510 {
2511- const QList< DocumentView* >::const_iterator at = qBinaryFind(m_views.constBegin(), m_views.constEnd(), view);
2512+ const QVector< DocumentView* >::const_iterator at = qBinaryFind(m_views.constBegin(), m_views.constEnd(), view);
2513 const int row = at - m_views.constBegin();
2514
2515 if(at == m_views.constEnd())
2516@@ -421,14 +427,11 @@
2517
2518 QModelIndex SearchModel::findOrInsertView(DocumentView* view)
2519 {
2520- QList< DocumentView* >::iterator at = qBinaryFind(m_views.begin(), m_views.end(), view);
2521- int row = at - m_views.begin();
2522+ const QVector< DocumentView* >::iterator at = qLowerBound(m_views.begin(), m_views.end(), view);
2523+ const int row = at - m_views.begin();
2524
2525- if(at == m_views.end())
2526+ if(at == m_views.end() || *at != view)
2527 {
2528- at = qUpperBound(m_views.begin(), m_views.end(), view);
2529- row = at - m_views.begin();
2530-
2531 beginInsertRows(QModelIndex(), row, row);
2532
2533 m_views.insert(at, view);
2534
2535=== modified file 'sources/searchmodel.h'
2536--- sources/searchmodel.h 2015-01-24 16:32:08 +0000
2537+++ sources/searchmodel.h 2017-04-19 21:02:47 +0000
2538@@ -95,7 +95,7 @@
2539 static SearchModel* s_instance;
2540 SearchModel(QObject* parent = 0);
2541
2542- QList< DocumentView* > m_views;
2543+ QVector< DocumentView* > m_views;
2544
2545 QModelIndex findView(DocumentView* view) const;
2546 QModelIndex findOrInsertView(DocumentView* view);
2547
2548=== modified file 'sources/settings.cpp'
2549--- sources/settings.cpp 2017-01-10 16:34:28 +0000
2550+++ sources/settings.cpp 2017-04-19 21:02:47 +0000
2551@@ -211,7 +211,7 @@
2552 return static_cast< Qt::KeyboardModifiers >(m_settings->value("pageItem/copyToClipboardModifiers", static_cast< int >(Defaults::PageItem::copyToClipboardModifiers())).toInt());
2553 }
2554
2555-void Settings::PageItem::setCopyToClipboardModifiers(const Qt::KeyboardModifiers& modifiers)
2556+void Settings::PageItem::setCopyToClipboardModifiers(Qt::KeyboardModifiers modifiers)
2557 {
2558 m_settings->setValue("pageItem/copyToClipboardModifiers", static_cast< int >(modifiers));
2559 }
2560@@ -221,7 +221,7 @@
2561 return static_cast< Qt::KeyboardModifiers >(m_settings->value("pageItem/addAnnotationModifiers", static_cast< int >(Defaults::PageItem::addAnnotationModifiers())).toInt());
2562 }
2563
2564-void Settings::PageItem::setAddAnnotationModifiers(const Qt::KeyboardModifiers& modifiers)
2565+void Settings::PageItem::setAddAnnotationModifiers(Qt::KeyboardModifiers modifiers)
2566 {
2567 m_settings->setValue("pageItem/addAnnotationModifiers", static_cast< int >(modifiers));
2568 }
2569@@ -231,7 +231,7 @@
2570 return static_cast< Qt::KeyboardModifiers>(m_settings->value("pageItem/zoomToSelectionModifiers", static_cast< int >(Defaults::PageItem::zoomToSelectionModifiers())).toInt());
2571 }
2572
2573-void Settings::PageItem::setZoomToSelectionModifiers(const Qt::KeyboardModifiers& modifiers)
2574+void Settings::PageItem::setZoomToSelectionModifiers(Qt::KeyboardModifiers modifiers)
2575 {
2576 m_settings->setValue("pageItem/zoomToSelectionModifiers", static_cast< int >(modifiers));
2577 }
2578@@ -241,7 +241,7 @@
2579 return static_cast< Qt::KeyboardModifiers >(m_settings->value("pageItem/openInSourceEditorModifiers", static_cast< int >(Defaults::PageItem::openInSourceEditorModifiers())).toInt());
2580 }
2581
2582-void Settings::PageItem::setOpenInSourceEditorModifiers(const Qt::KeyboardModifiers& modifiers)
2583+void Settings::PageItem::setOpenInSourceEditorModifiers(Qt::KeyboardModifiers modifiers)
2584 {
2585 m_settings->setValue("pageItem/openInSourceEditorModifiers", static_cast< int >(modifiers));
2586 }
2587@@ -523,7 +523,7 @@
2588 return static_cast< Qt::KeyboardModifiers >(m_settings->value("documentView/zoomModifiers", static_cast< int >(Defaults::DocumentView::zoomModifiers())).toInt());
2589 }
2590
2591-void Settings::DocumentView::setZoomModifiers(const Qt::KeyboardModifiers& zoomModifiers)
2592+void Settings::DocumentView::setZoomModifiers(Qt::KeyboardModifiers zoomModifiers)
2593 {
2594 m_settings->setValue("documentView/zoomModifiers", static_cast< int >(zoomModifiers));
2595 }
2596@@ -533,7 +533,7 @@
2597 return static_cast< Qt::KeyboardModifiers >(m_settings->value("documentView/rotateModifiers", static_cast< int >(Defaults::DocumentView::rotateModifiers())).toInt());
2598 }
2599
2600-void Settings::DocumentView::setRotateModifiers(const Qt::KeyboardModifiers& rotateModifiers)
2601+void Settings::DocumentView::setRotateModifiers(Qt::KeyboardModifiers rotateModifiers)
2602 {
2603 m_settings->setValue("documentView/rotateModifiers", static_cast< int >(rotateModifiers));
2604 }
2605@@ -543,7 +543,7 @@
2606 return static_cast< Qt::KeyboardModifiers >(m_settings->value("documentView/scrollModifiers", static_cast< int >(Defaults::DocumentView::scrollModifiers())).toInt());
2607 }
2608
2609-void Settings::DocumentView::setScrollModifiers(const Qt::KeyboardModifiers& scrollModifiers)
2610+void Settings::DocumentView::setScrollModifiers(Qt::KeyboardModifiers scrollModifiers)
2611 {
2612 m_settings->setValue("documentView/scrollModifiers", static_cast< int >(scrollModifiers));
2613 }
2614@@ -863,7 +863,7 @@
2615
2616 void Settings::MainWindow::setExtendedSearchDock(bool extendedSearchDock)
2617 {
2618- return m_settings->setValue("mainWindow/extendedSearchDock", extendedSearchDock);
2619+ m_settings->setValue("mainWindow/extendedSearchDock", extendedSearchDock);
2620 }
2621
2622 bool Settings::MainWindow::usePageLabel() const
2623@@ -886,6 +886,16 @@
2624 m_settings->setValue("mainWindow/synchronizeOutlineView", synchronizeOutlineView);
2625 }
2626
2627+bool Settings::MainWindow::synchronizeSplitViews() const
2628+{
2629+ return m_settings->value("mainWindow/synchronizeSplitViews", Defaults::MainWindow::synchronizeSplitViews()).toBool();
2630+}
2631+
2632+void Settings::MainWindow::setSynchronizeSplitViews(bool synchronizeSplitViews)
2633+{
2634+ m_settings->setValue("mainWindow/synchronizeSplitViews", synchronizeSplitViews);
2635+}
2636+
2637 QStringList Settings::MainWindow::fileToolBar() const
2638 {
2639 return m_settings->value("mainWindow/fileToolBar", Defaults::MainWindow::fileToolBar()).toStringList();
2640@@ -1026,32 +1036,32 @@
2641 m_settings->setValue("mainWindow/savePath", savePath);
2642 }
2643
2644-QSize Settings::MainWindow::settingsDialogSize(const QSize& sizeHint) const
2645+QSize Settings::MainWindow::settingsDialogSize(QSize sizeHint) const
2646 {
2647 return m_settings->value("mainWindow/settingsDialogSize", sizeHint).toSize();
2648 }
2649
2650-void Settings::MainWindow::setSettingsDialogSize(const QSize& settingsDialogSize)
2651+void Settings::MainWindow::setSettingsDialogSize(QSize settingsDialogSize)
2652 {
2653 m_settings->setValue("mainWindow/settingsDialogSize", settingsDialogSize);
2654 }
2655
2656-QSize Settings::MainWindow::fontsDialogSize(const QSize& sizeHint) const
2657+QSize Settings::MainWindow::fontsDialogSize(QSize sizeHint) const
2658 {
2659 return m_settings->value("mainWindow/fontsDialogSize", sizeHint).toSize();
2660 }
2661
2662-void Settings::MainWindow::setFontsDialogSize(const QSize& fontsDialogSize)
2663+void Settings::MainWindow::setFontsDialogSize(QSize fontsDialogSize)
2664 {
2665 m_settings->setValue("mainWindow/fontsDialogSize", fontsDialogSize);
2666 }
2667
2668-QSize Settings::MainWindow::contentsDialogSize(const QSize& sizeHint) const
2669+QSize Settings::MainWindow::contentsDialogSize(QSize sizeHint) const
2670 {
2671 return m_settings->value("mainWindow/contentsDialogSize", sizeHint).toSize();
2672 }
2673
2674-void Settings::MainWindow::setContentsDialogSize(const QSize& contentsDialogSize)
2675+void Settings::MainWindow::setContentsDialogSize(QSize contentsDialogSize)
2676 {
2677 m_settings->setValue("mainWindow/contentsDialogSize", contentsDialogSize);
2678 }
2679
2680=== modified file 'sources/settings.h'
2681--- sources/settings.h 2017-01-10 16:34:28 +0000
2682+++ sources/settings.h 2017-04-19 21:02:47 +0000
2683@@ -95,16 +95,16 @@
2684 void setAnnotationColor(const QColor& annotationColor);
2685
2686 Qt::KeyboardModifiers copyToClipboardModifiers() const;
2687- void setCopyToClipboardModifiers(const Qt::KeyboardModifiers& modifiers);
2688+ void setCopyToClipboardModifiers(Qt::KeyboardModifiers modifiers);
2689
2690 Qt::KeyboardModifiers addAnnotationModifiers() const;
2691- void setAddAnnotationModifiers(const Qt::KeyboardModifiers& modifiers);
2692+ void setAddAnnotationModifiers(Qt::KeyboardModifiers modifiers);
2693
2694 Qt::KeyboardModifiers zoomToSelectionModifiers() const;
2695- void setZoomToSelectionModifiers(const Qt::KeyboardModifiers& modifiers);
2696+ void setZoomToSelectionModifiers(Qt::KeyboardModifiers modifiers);
2697
2698 Qt::KeyboardModifiers openInSourceEditorModifiers() const;
2699- void setOpenInSourceEditorModifiers(const Qt::KeyboardModifiers& modifiers);
2700+ void setOpenInSourceEditorModifiers(Qt::KeyboardModifiers modifiers);
2701
2702 bool annotationOverlay() const;
2703 void setAnnotationOverlay(bool overlay);
2704@@ -228,13 +228,13 @@
2705 void setSourceEditor(const QString& sourceEditor);
2706
2707 Qt::KeyboardModifiers zoomModifiers() const;
2708- void setZoomModifiers(const Qt::KeyboardModifiers& zoomModifiers);
2709+ void setZoomModifiers(Qt::KeyboardModifiers zoomModifiers);
2710
2711 Qt::KeyboardModifiers rotateModifiers() const;
2712- void setRotateModifiers(const Qt::KeyboardModifiers& rotateModifiers);
2713+ void setRotateModifiers(Qt::KeyboardModifiers rotateModifiers);
2714
2715 Qt::KeyboardModifiers scrollModifiers() const;
2716- void setScrollModifiers(const Qt::KeyboardModifiers& scrollModifiers);
2717+ void setScrollModifiers(Qt::KeyboardModifiers scrollModifiers);
2718
2719 // per-tab settings
2720
2721@@ -361,6 +361,9 @@
2722 bool synchronizeOutlineView() const;
2723 void setSynchronizeOutlineView(bool synchronizeOutlineView);
2724
2725+ bool synchronizeSplitViews() const;
2726+ void setSynchronizeSplitViews(bool synchronizeSplitViews);
2727+
2728 QStringList fileToolBar() const;
2729 void setFileToolBar(const QStringList& fileToolBar);
2730
2731@@ -403,14 +406,14 @@
2732 QString savePath() const;
2733 void setSavePath(const QString& savePath);
2734
2735- QSize settingsDialogSize(const QSize& sizeHint) const;
2736- void setSettingsDialogSize(const QSize& settingsDialogSize);
2737-
2738- QSize fontsDialogSize(const QSize& sizeHint) const;
2739- void setFontsDialogSize(const QSize& fontsDialogSize);
2740-
2741- QSize contentsDialogSize(const QSize& sizeHint) const;
2742- void setContentsDialogSize(const QSize& contentsDialogSize);
2743+ QSize settingsDialogSize(QSize sizeHint) const;
2744+ void setSettingsDialogSize(QSize settingsDialogSize);
2745+
2746+ QSize fontsDialogSize(QSize sizeHint) const;
2747+ void setFontsDialogSize(QSize fontsDialogSize);
2748+
2749+ QSize contentsDialogSize(QSize sizeHint) const;
2750+ void setContentsDialogSize(QSize contentsDialogSize);
2751
2752 private:
2753 MainWindow(QSettings* settings);
2754@@ -640,13 +643,14 @@
2755 static bool usePageLabel() { return true; }
2756
2757 static bool synchronizeOutlineView() { return false; }
2758+ static bool synchronizeSplitViews() { return true; }
2759
2760 static QStringList fileToolBar() { return QStringList() << "openInNewTab" << "refresh"; }
2761 static QStringList editToolBar() { return QStringList() << "currentPage" << "previousPage" << "nextPage"; }
2762 static QStringList viewToolBar() { return QStringList() << "scaleFactor" << "zoomIn" << "zoomOut"; }
2763
2764 static QStringList documentContextMenu() { return QStringList() << "previousPage" << "nextPage" << "firstPage" << "lastPage" << "separator" << "jumpToPage" << "jumpBackward" << "jumpForward" << "separator" << "setFirstPage" << "separator" << "findPrevious" << "findNext" << "cancelSearch"; }
2765- static QStringList tabContexntMenu() { return QStringList() << "openCopyInNewTab" << "openContainingFolder" << "separator" << "closeAllTabs" << "closeAllTabsButThisOne" << "closeAllTabsToTheLeft" << "closeAllTabsToTheRight"; }
2766+ static QStringList tabContexntMenu() { return QStringList() << "openCopyInNewTab" << "openContainingFolder" << "separator" << "splitViewHorizontally" << "splitViewVertically" << "closeCurrentView" << "separator" << "closeAllTabs" << "closeAllTabsButThisOne" << "closeAllTabsToTheLeft" << "closeAllTabsToTheRight"; }
2767
2768 static bool scrollableMenus() { return false; }
2769 static bool searchableMenus() { return false; }
2770
2771=== modified file 'sources/settingsdialog.cpp'
2772--- sources/settingsdialog.cpp 2017-01-10 16:34:28 +0000
2773+++ sources/settingsdialog.cpp 2017-04-19 21:02:47 +0000
2774@@ -78,7 +78,7 @@
2775 return color.isValid() ? color : defaultColor;
2776 }
2777
2778-void setCurrentIndexFromKeyboardModifiers(QComboBox* comboBox, const Qt::KeyboardModifiers& modifiers)
2779+void setCurrentIndexFromKeyboardModifiers(QComboBox* comboBox, Qt::KeyboardModifiers modifiers)
2780 {
2781 comboBox->setCurrentIndex(comboBox->findData(static_cast< int >(modifiers)));
2782 }
2783@@ -288,6 +288,9 @@
2784 m_synchronizeOutlineViewCheckBox = addCheckBox(m_behaviorLayout, tr("Synchronize outline view:"), QString(),
2785 s_settings->mainWindow().synchronizeOutlineView());
2786
2787+ m_synchronizeSplitViewsCheckBox = addCheckBox(m_behaviorLayout, tr("Synchronize split views:"), QString(),
2788+ s_settings->mainWindow().synchronizeSplitViews());
2789+
2790
2791 m_minimalScrollingCheckBox = addCheckBox(m_behaviorLayout, tr("Minimal scrolling:"), QString(),
2792 s_settings->documentView().minimalScrolling());
2793@@ -331,6 +334,7 @@
2794 s_settings->presentationView().setScreen(m_presentationScreenSpinBox->value());
2795
2796 s_settings->mainWindow().setSynchronizeOutlineView(m_synchronizeOutlineViewCheckBox->isChecked());
2797+ s_settings->mainWindow().setSynchronizeSplitViews(m_synchronizeSplitViewsCheckBox->isChecked());
2798
2799 s_settings->documentView().setMinimalScrolling(m_minimalScrollingCheckBox->isChecked());
2800 s_settings->documentView().setZoomFactor(m_zoomFactorSpinBox->value());
2801@@ -361,6 +365,7 @@
2802 m_presentationScreenSpinBox->setValue(Defaults::PresentationView::screen());
2803
2804 m_synchronizeOutlineViewCheckBox->setChecked(Defaults::MainWindow::synchronizeOutlineView());
2805+ m_synchronizeSplitViewsCheckBox->setChecked(Defaults::MainWindow::synchronizeSplitViews());
2806
2807 m_minimalScrollingCheckBox->setChecked(Defaults::DocumentView::minimalScrolling());
2808 m_zoomFactorSpinBox->setValue(Defaults::DocumentView::zoomFactor());
2809@@ -849,7 +854,7 @@
2810 return comboBox;
2811 }
2812
2813-QComboBox* SettingsDialog::addModifiersComboBox(QFormLayout* layout, const QString& label, const QString& toolTip, const Qt::KeyboardModifiers& modifiers)
2814+QComboBox* SettingsDialog::addModifiersComboBox(QFormLayout* layout, const QString& label, const QString& toolTip, Qt::KeyboardModifiers modifiers)
2815 {
2816 QComboBox* comboBox = new QComboBox(this);
2817 comboBox->addItem(QShortcut::tr("Shift"), static_cast< int >(Qt::ShiftModifier));
2818
2819=== modified file 'sources/settingsdialog.h'
2820--- sources/settingsdialog.h 2017-01-10 16:34:28 +0000
2821+++ sources/settingsdialog.h 2017-04-19 21:02:47 +0000
2822@@ -102,6 +102,7 @@
2823 QSpinBox* m_presentationScreenSpinBox;
2824
2825 QCheckBox* m_synchronizeOutlineViewCheckBox;
2826+ QCheckBox* m_synchronizeSplitViewsCheckBox;
2827
2828 QCheckBox* m_minimalScrollingCheckBox;
2829 QDoubleSpinBox* m_zoomFactorSpinBox;
2830@@ -212,7 +213,7 @@
2831 QComboBox* addComboBox(QFormLayout* layout, const QString& label, const QString& toolTip, const QStringList& text, const QList< int >& data, int value);
2832 QComboBox* addDataSizeComboBox(QFormLayout* layout, const QString& label, const QString& toolTip, int initialDataSize);
2833 QComboBox* addColorComboBox(QFormLayout* layout, const QString& label, const QString& toolTip, const QColor& color);
2834- QComboBox* addModifiersComboBox(QFormLayout* layout, const QString& label, const QString& toolTip, const Qt::KeyboardModifiers& modifiers);
2835+ QComboBox* addModifiersComboBox(QFormLayout* layout, const QString& label, const QString& toolTip, Qt::KeyboardModifiers modifiers);
2836
2837 };
2838
2839
2840=== modified file 'sources/tileitem.cpp'
2841--- sources/tileitem.cpp 2016-11-26 18:32:17 +0000
2842+++ sources/tileitem.cpp 2017-04-19 21:02:47 +0000
2843@@ -84,7 +84,7 @@
2844
2845 void TileItem::dropCachedPixmaps(PageItem* page)
2846 {
2847- foreach(CacheKey key, s_cache.keys())
2848+ foreach(const CacheKey& key, s_cache.keys())
2849 {
2850 if(key.first == page)
2851 {
2852@@ -93,7 +93,7 @@
2853 }
2854 }
2855
2856-bool TileItem::paint(QPainter* painter, const QPointF& topLeft)
2857+bool TileItem::paint(QPainter* painter, QPointF topLeft)
2858 {
2859 const QPixmap& pixmap = takePixmap();
2860
2861@@ -201,8 +201,8 @@
2862 }
2863
2864 void TileItem::on_finished(const RenderParam& renderParam,
2865- const QRect& rect, bool prefetch,
2866- const QImage& image, const QRectF& cropRect)
2867+ const QRect& rect, bool prefetch,
2868+ const QImage& image, const QRectF& cropRect)
2869 {
2870 if(m_page->m_renderParam != renderParam || m_rect != rect)
2871 {
2872
2873=== modified file 'sources/tileitem.h'
2874--- sources/tileitem.h 2016-11-26 18:32:17 +0000
2875+++ sources/tileitem.h 2017-04-19 21:02:47 +0000
2876@@ -40,7 +40,7 @@
2877 ~TileItem();
2878
2879 const QRect& rect() const { return m_rect; }
2880- void setRect(const QRect& rect) { m_rect = rect; }
2881+ void setRect(QRect rect) { m_rect = rect; }
2882
2883 const QRectF& cropRect() const { return m_cropRect; }
2884 void resetCropRect() { m_cropRect = QRectF(); }
2885@@ -51,7 +51,7 @@
2886
2887 static void dropCachedPixmaps(PageItem* page);
2888
2889- bool paint(QPainter* painter, const QPointF& topLeft);
2890+ bool paint(QPainter* painter, QPointF topLeft);
2891
2892 public:
2893 void refresh(bool keepObsoletePixmaps = false);

Subscribers

People subscribed via source and target branches

to all changes: