From: Stefan Bund Date: Tue, 21 Dec 2010 09:00:10 +0000 (+0100) Subject: remove obsolete zooming functions X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=596a9473c43be8768f12b12d50ec83d0b8f1fded;p=pykit.git remove obsolete zooming functions --- diff --git a/PDFWidget.cc b/PDFWidget.cc index e27939b..d6e1417 100644 --- a/PDFWidget.cc +++ b/PDFWidget.cc @@ -23,7 +23,7 @@ prefix_ pykit::PDFWidget::PDFWidget(QString const & id, QNetworkAccessManager * manager, QWidget * parent) - : QLabel(parent), id_ (id), manager_ (manager), currentPage_ (0), dpi_ (96.0), x_ (0), y_ (0) + : QLabel(parent), id_ (id), manager_ (manager), currentPage_ (0) { QWebView * webView (dynamic_cast(parent)); @@ -33,7 +33,7 @@ prefix_ pykit::PDFWidget::PDFWidget(QString const & id, QNetworkAccessManager * prefix_ pykit::PDFWidget::PDFWidget(QString const & id, QString const & document, QNetworkAccessManager * manager, QWidget * parent) - : QLabel(parent), id_ (id), manager_ (manager), currentPage_ (0), dpi_ (96.0), x_ (0), y_ (0) + : QLabel(parent), id_ (id), manager_ (manager), currentPage_ (0) { setFocusPolicy(Qt::WheelFocus); @@ -51,134 +51,18 @@ prefix_ void pykit::PDFWidget::load(QUrl const & url) connect(reply, SIGNAL(finished()), this, SLOT(netLoadDocument())); } -prefix_ void pykit::PDFWidget::zoomIn() -{ - zoomMode_ = Manual; - double n (dpi_ + ZoomStepDpi); - if (n > ZoomMaxDpi) - n = ZoomMaxDpi; - if (n != dpi_) { - dpi_ = n; - showPage(); - } -} - -prefix_ void pykit::PDFWidget::zoomOut() -{ - zoomMode_ = Manual; - double n (dpi_ - ZoomStepDpi); - if (n < ZoomMinDpi) - n = ZoomMinDpi; - if (n != dpi_) { - dpi_ = n; - showPage(); - } -} - -prefix_ void pykit::PDFWidget::zoomDPI(double dpi) -{ - zoomMode_ = Manual; - if (dpi < ZoomMinDpi) - dpi = ZoomMinDpi; - if (dpi > ZoomMaxDpi) - dpi = ZoomMaxDpi; - if (dpi != dpi_) { - dpi_ = dpi; - showPage(); - } -} - -prefix_ int pykit::PDFWidget::zoomWidth(int w) -{ - zoomMode_ = Width; - if (! document_) - return 0; - if (w == -1) - w = width(); - QSizeF pageSize (document_->page(currentPage_)->pageSizeF()); - double n = 72.0 * w / pageSize.width(); - if (n > ZoomMaxDpi) - n = ZoomMaxDpi; - if (n < ZoomMinDpi) - n = ZoomMinDpi; - if (n != dpi_) { - dpi_ = n; - showPage(); - } - return pageSize.height() * dpi_ / 72.0; -} - -prefix_ int pykit::PDFWidget::zoomHeight() -{ - zoomMode_ = Height; - if (! document_) - return 0; - QSizeF pageSize (document_->page(currentPage_)->pageSizeF()); - double n = 72.0 * height() / pageSize.height(); - if (n > ZoomMaxDpi) - n = ZoomMaxDpi; - if (n < ZoomMinDpi) - n = ZoomMinDpi; - if (n != dpi_) { - dpi_ = n; - showPage(); - } - return pageSize.width() * dpi_ / 72.0; -} - -prefix_ void pykit::PDFWidget::zoomFit() +prefix_ void pykit::PDFWidget::resizeEvent(QResizeEvent *) { - zoomMode_ = Fit; if (! document_) return; QSizeF pageSize (document_->page(currentPage_)->pageSizeF()); - double xres = 72.0 * width() / pageSize.width(); - double yres = 72.0 * height() / pageSize.height(); - double n = xres < yres ? xres : yres; - if (n > ZoomMaxDpi) - n = ZoomMaxDpi; - if (n < ZoomMinDpi) - n = ZoomMinDpi; - if (n != dpi_) { + double n = 72.0 * width() / pageSize.width(); + if (n != dpi_) { dpi_ = n; showPage(); } } -prefix_ int pykit::PDFWidget::getPDFWidth() -{ - if (! document_) - return 0; - QSizeF pageSize (document_->page(currentPage_)->pageSizeF()); - return pageSize.width() * dpi_ / 72.0; -} - -prefix_ int pykit::PDFWidget::getPDFHeight() -{ - if (! document_) - return 0; - QSizeF pageSize (document_->page(currentPage_)->pageSizeF()); - return pageSize.height() * dpi_ / 72.0; -} - -prefix_ void pykit::PDFWidget::resizeEvent(QResizeEvent *) -{ - switch (zoomMode_) { - case Manual: - break; - case Width: - zoomWidth(); - break; - case Height: - zoomHeight(); - break; - case Fit: - zoomFit(); - break; - } - showPage(); -} - prefix_ void pykit::PDFWidget::netLoadDocument() { QNetworkReply * reply = static_cast(sender()); @@ -197,7 +81,7 @@ prefix_ void pykit::PDFWidget::documentSetup() document_->setRenderHint(Poppler::Document::Antialiasing, true); document_->setRenderHint(Poppler::Document::TextAntialiasing, true); document_->setRenderHint(Poppler::Document::TextHinting, false); - zoomFit(); + resizeEvent(0); showPage(); } @@ -206,7 +90,7 @@ prefix_ void pykit::PDFWidget::showPage() if (! document_) return; QImage image (document_->page(currentPage_)->renderToImage( - dpi_, dpi_, x_, y_, width(), height())); + dpi_, dpi_, 0, 0, width(), height())); setPixmap(QPixmap::fromImage(image)); } diff --git a/PDFWidget.hh b/PDFWidget.hh index 9a82461..3c9cb51 100644 --- a/PDFWidget.hh +++ b/PDFWidget.hh @@ -34,18 +34,6 @@ namespace pykit { void load(QUrl const & url); - public slots: - void zoomIn(); - void zoomOut(); - void zoomDPI(double dpi); - - int zoomWidth(int w = -1); - int zoomHeight(); - void zoomFit(); - - int getPDFWidth(); - int getPDFHeight(); - protected: virtual void resizeEvent(QResizeEvent * event); @@ -56,19 +44,11 @@ namespace pykit { void documentSetup(); void showPage(); - enum ZoomMode { Manual, Width, Height, Fit }; - static double const ZoomStepDpi = 20.0; - static double const ZoomMaxDpi = 200.0; - static double const ZoomMinDpi = 50.0; - QString id_; QNetworkAccessManager * manager_; boost::scoped_ptr document_; int currentPage_; - ZoomMode zoomMode_; double dpi_; - int x_; - int y_; }; }