Issue #126: Remove <QtCore> include from main headers

This commit is contained in:
Jakub Melka
2023-12-21 14:25:41 +01:00
parent e5e25a71a3
commit 9f624e5569
87 changed files with 171 additions and 72 deletions

View File

@@ -22,12 +22,13 @@
#include "pdfcompiler.h"
#include "pdfwidgetformmanager.h"
#include "pdfwidgetannotation.h"
#include "pdfdbgheap.h"
#include <QActionGroup>
#include <QInputDialog>
#include <QKeyEvent>
#include "pdfdbgheap.h"
namespace pdf
{

View File

@@ -27,6 +27,7 @@
#include <QDesktopServices>
#include <QMessageBox>
#include <QFileDialog>
#include <QStandardPaths>
namespace pdf
{

View File

@@ -21,10 +21,12 @@
#include "pdfexecutionpolicy.h"
#include "pdftextlayoutgenerator.h"
#include "pdfdrawspacecontroller.h"
#include "pdfdbgheap.h"
#include <QCache>
#include <QtConcurrent/QtConcurrent>
#include "pdfdbgheap.h"
#include <execution>
namespace pdf
@@ -114,14 +116,18 @@ void PDFAsynchronousPageCompilerWorkerThread::run()
PDFAsynchronousPageCompiler::PDFAsynchronousPageCompiler(PDFDrawWidgetProxy* proxy) :
BaseClass(proxy),
m_proxy(proxy)
m_proxy(proxy),
m_cache(new QCache<PDFInteger, PDFPrecompiledPage>())
{
m_cache.setMaxCost(128 * 1024 * 1024);
m_cache->setMaxCost(128 * 1024 * 1024);
}
PDFAsynchronousPageCompiler::~PDFAsynchronousPageCompiler()
{
stop(true);
delete m_cache;
m_cache = nullptr;
}
bool PDFAsynchronousPageCompiler::isOperationCancelled() const
@@ -183,7 +189,7 @@ void PDFAsynchronousPageCompiler::stop(bool clearCache)
if (clearCache)
{
m_cache.clear();
m_cache->clear();
}
m_state = State::Inactive;
@@ -207,7 +213,7 @@ void PDFAsynchronousPageCompiler::reset()
void PDFAsynchronousPageCompiler::setCacheLimit(int limit)
{
m_cache.setMaxCost(limit);
m_cache->setMaxCost(limit);
}
const PDFPrecompiledPage* PDFAsynchronousPageCompiler::getCompiledPage(PDFInteger pageIndex, bool compile)
@@ -218,7 +224,7 @@ const PDFPrecompiledPage* PDFAsynchronousPageCompiler::getCompiledPage(PDFIntege
return nullptr;
}
PDFPrecompiledPage* page = m_cache.object(pageIndex);
PDFPrecompiledPage* page = m_cache->object(pageIndex);
if (!page && compile)
{
@@ -250,7 +256,7 @@ void PDFAsynchronousPageCompiler::smartClearCache(const int milisecondsLimit, co
Q_ASSERT(std::is_sorted(activePages.cbegin(), activePages.cend()));
QList<PDFInteger> pageIndices = m_cache.keys();
QList<PDFInteger> pageIndices = m_cache->keys();
for (const PDFInteger pageIndex : pageIndices)
{
if (std::binary_search(activePages.cbegin(), activePages.cend(), pageIndex))
@@ -259,10 +265,10 @@ void PDFAsynchronousPageCompiler::smartClearCache(const int milisecondsLimit, co
continue;
}
const PDFPrecompiledPage* page = m_cache.object(pageIndex);
const PDFPrecompiledPage* page = m_cache->object(pageIndex);
if (page && page->hasExpired(milisecondsLimit))
{
m_cache.remove(pageIndex);
m_cache->remove(pageIndex);
}
}
}
@@ -287,7 +293,7 @@ void PDFAsynchronousPageCompiler::onPageCompiled()
PDFPrecompiledPage* page = new PDFPrecompiledPage(std::move(task.precompiledPage));
page->markAccessed();
qint64 memoryConsumptionEstimate = page->getMemoryConsumptionEstimate();
if (m_cache.insert(it->first, page, memoryConsumptionEstimate))
if (m_cache->insert(it->first, page, memoryConsumptionEstimate))
{
compiledPages.push_back(it->first);
}
@@ -295,7 +301,7 @@ void PDFAsynchronousPageCompiler::onPageCompiled()
{
// We can't insert page to the cache, because cache size is too small. We will
// emit error string to inform the user, that cache is too small.
QString message = PDFTranslationContext::tr("Precompiled page size is too high (%1 kB). Cache size is %2 kB. Increase the cache size!").arg(memoryConsumptionEstimate / 1024).arg(m_cache.maxCost() / 1024);
QString message = PDFTranslationContext::tr("Precompiled page size is too high (%1 kB). Cache size is %2 kB. Increase the cache size!").arg(memoryConsumptionEstimate / 1024).arg(m_cache->maxCost() / 1024);
errors[it->first] = PDFRenderError(RenderErrorType::Error, message);
}
}

View File

@@ -24,11 +24,13 @@
#include "pdfpainter.h"
#include "pdftextlayout.h"
#include <QCache>
#include <QFuture>
#include <QFutureWatcher>
#include <QWaitCondition>
template <class Key, class T>
class QCache;
namespace pdf
{
class PDFDrawWidgetProxy;
@@ -143,7 +145,7 @@ private:
PDFAsynchronousPageCompilerWorkerThread* m_thread = nullptr;
PDFDrawWidgetProxy* m_proxy;
QCache<PDFInteger, PDFPrecompiledPage> m_cache;
QCache<PDFInteger, PDFPrecompiledPage>* m_cache;
/// This task is protected by mutex. Every access to this
/// variable must be done with locked mutex.

View File

@@ -24,7 +24,6 @@
#include "pdfannotation.h"
#include "pdfdrawwidget.h"
#include "pdfwidgetannotation.h"
#include "pdfdbgheap.h"
#include <QTimer>
#include <QPainter>
@@ -32,6 +31,8 @@
#include <QScreen>
#include <QGuiApplication>
#include "pdfdbgheap.h"
namespace pdf
{

View File

@@ -22,7 +22,6 @@
#include "pdfannotation.h"
#include "pdfwidgetannotation.h"
#include "pdfwidgetformmanager.h"
#include "pdfdbgheap.h"
#include <QPainter>
#include <QGridLayout>
@@ -31,6 +30,8 @@
#include <QPixmapCache>
#include <QColorSpace>
#include "pdfdbgheap.h"
namespace pdf
{

View File

@@ -18,7 +18,6 @@
#include "pdfitemmodels.h"
#include "pdfdocument.h"
#include "pdfdrawspacecontroller.h"
#include "pdfdbgheap.h"
#include "pdfdrawwidget.h"
#include <QFont>
@@ -26,6 +25,9 @@
#include <QApplication>
#include <QMimeDatabase>
#include <QFileIconProvider>
#include <QMimeData>
#include "pdfdbgheap.h"
namespace pdf
{

View File

@@ -20,7 +20,6 @@
#include "pdfdocumentbuilder.h"
#include "pdfencoding.h"
#include "pdfwidgetutils.h"
#include "pdfdbgheap.h"
#include <QTabWidget>
#include <QVBoxLayout>
@@ -37,6 +36,8 @@
#include <QDialogButtonBox>
#include <QDoubleSpinBox>
#include "pdfdbgheap.h"
namespace pdf
{

View File

@@ -27,6 +27,7 @@
#include <QFileDialog>
#include <QImageReader>
#include <QGuiApplication>
#include <QStandardPaths>
namespace pdf
{

View File

@@ -22,6 +22,7 @@
#include "pdfwidgetutils.h"
#include "pdfutils.h"
#include <QBuffer>
#include <QPainter>
#include <QKeyEvent>
#include <QMouseEvent>

View File

@@ -26,6 +26,7 @@
#include <QBrush>
#include <QCursor>
#include <QPainterPath>
#include <QElapsedTimer>
#include <set>

View File

@@ -17,10 +17,10 @@
#include "pdfrenderingerrorswidget.h"
#include "pdfdrawwidget.h"
#include "pdfdbgheap.h"
#include "ui_pdfrenderingerrorswidget.h"
#include "pdfwidgetutils.h"
#include "pdfdbgheap.h"
namespace pdf
{

View File

@@ -16,10 +16,10 @@
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#include "pdfselectpagesdialog.h"
#include "pdfdbgheap.h"
#include "ui_pdfselectpagesdialog.h"
#include "pdfwidgetutils.h"
#include "pdfdbgheap.h"
#include <QMessageBox>

View File

@@ -20,7 +20,6 @@
#include "pdfcompiler.h"
#include "pdfwidgetutils.h"
#include "pdfpainterutils.h"
#include "pdfdbgheap.h"
#include <QLabel>
#include <QAction>
@@ -36,6 +35,8 @@
#include <QStylePainter>
#include <QStyleOptionTitleBar>
#include "pdfdbgheap.h"
namespace pdf
{

View File

@@ -17,7 +17,6 @@
#include "pdfwidgetutils.h"
#include "pdfcolorconvertor.h"
#include "pdfdbgheap.h"
#include <QDialog>
#include <QLayout>
@@ -26,6 +25,8 @@
#include <QGroupBox>
#include <QApplication>
#include "pdfdbgheap.h"
#ifdef Q_OS_MAC
int qt_default_dpi_x() { return 72; }
int qt_default_dpi_y() { return 72; }