void PdfImageGenerator::startGeneration(void) { int page; QRectF highlight; QImage img; QPair<int,QRectF> demand; while (!this->requestedPages.isEmpty()) { demand = requestedPages.takeLast(); page = demand.first; highlight = demand.second; img = generateImage(page); if (!img.isNull()) { /* image size estimation */ if (this->passes < this->minpasses) { ++passes; avgw += img.width(); avgh += img.height(); } /* search result highlight * cuts out the highlighted word and darkens the rest of the page */ if (highlight.isValid()) { QRect highlightRect = scaleHighlightRect(highlight); highlightRect.adjust(-2, -2, 2, 2); QImage hImage = img.copy(highlightRect); QPainter painter; painter.begin(&img); painter.fillRect(img.rect(), QColor(0, 0, 0, 32)); painter.drawImage(highlightRect, hImage); painter.end(); } emit imageFinished(img, page); } } if (this->passes == minpasses) { pageSize.setWidth((int)(avgw/passes)); pageSize.setHeight((int)(avgh/passes)); ++passes; emit newPageSize(pageSize); } emit generationFinished(); }
/*! Constructs widgets and connections of signals for the main window. */ void MPWindow::initUIComponents() { // Initialise view m_view = new MPMapView(this); connect(m_view, SIGNAL(interactionChanged(Interaction*)), this, SLOT(onInteractionChanged(Interaction*))); connect(m_view, SIGNAL(viewportShift()), this, SLOT(onViewShift())); connect(m_view, SIGNAL(painted(qlonglong)), this, SLOT(onViewPainted(qlonglong))); connect(m_view, SIGNAL(imageRequested(int)), this, SLOT(onViewImageRequested(int))); connect(m_view, SIGNAL(imageReceived()), this, SLOT(onViewImageReceived())); connect(m_view, SIGNAL(imageFinished()), this, SLOT(onViewImageFinished())); connect(m_view, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(onViewMouseMove(QMouseEvent*))); connect(m_view, SIGNAL(featureSnap(Feature*)), this, SLOT(onViewFeatureSnap(Feature*))); setCentralWidget(m_view); // Docks m_infosdock = new InfosDock(this); m_infosdock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::LeftDockWidgetArea); addDockWidget(Qt::RightDockWidgetArea, m_infosdock); connect(m_infosdock, SIGNAL(dockClosed(bool)), this, SLOT(onDisplayInfosDock(bool))); // Status bar m_coordsLabel = new CoordField(this); connect(m_coordsLabel, SIGNAL(centerView(qreal,qreal)), this, SLOT(onCenterView(qreal,qreal))); m_meterPerPixelLabel = new QLabel(this); m_zoomlevelLabel = new QLabel(this); m_paintTimeLabel = new QLabel(this); m_paintTimeLabel->setMinimumWidth(23); m_dataProgress = new QProgressBar(this); m_dataProgress->setMaximumWidth(200); m_dataProgress->setVisible(false); m_imagesProgress = new QProgressBar(this); m_imagesProgress->setMaximumWidth(200); m_imagesProgress->setFormat(tr("tile %v / %m")); m_wsProgress = new QProgressBar(this); m_wsProgress->setMaximumWidth(200); m_wsProgress->setTextVisible(true); m_wsProgress->setFormat(tr("Requesting...")); // This has no effects, because max = 0 m_wsProgress->setVisible(false); m_wsProgress->setMaximum(0); // Separators m_sepCoordZoom = new QFrame(this); m_sepCoordZoom->setFrameStyle(QFrame::VLine); m_sepZoomScale = new QFrame(this); m_sepZoomScale->setFrameStyle(QFrame::VLine); m_sepScaleTime = new QFrame(this); m_sepScaleTime->setFrameStyle(QFrame::VLine); statusBar()->addPermanentWidget(m_imagesProgress); statusBar()->addPermanentWidget(m_dataProgress); statusBar()->addPermanentWidget(m_wsProgress); statusBar()->addPermanentWidget(m_coordsLabel); statusBar()->addPermanentWidget(m_sepCoordZoom); statusBar()->addPermanentWidget(m_zoomlevelLabel); statusBar()->addPermanentWidget(m_sepZoomScale); statusBar()->addPermanentWidget(m_meterPerPixelLabel); statusBar()->addPermanentWidget(m_sepScaleTime); statusBar()->addPermanentWidget(m_paintTimeLabel); }