[Kde-bindings] KDE/kdegraphics/okular

John Layt john at layt.net
Fri Jun 4 08:25:26 UTC 2010


SVN commit 1134379 by jlayt:

Enable Current Page option in Okular print dialog if running Qt >= 4.7

Changed exported api so cc: to bindings.
CCMAIL: kde-bindings at kde.org

CCBUG: 194586



 M  +8 -2      core/fileprinter.cpp  
 M  +3 -2      core/fileprinter.h  
 M  +1 -0      generators/comicbook/generator_comicbook.cpp  
 M  +1 -0      generators/djvu/generator_djvu.cpp  
 M  +1 -0      generators/dvi/generator_dvi.cpp  
 M  +1 -0      generators/poppler/generator_pdf.cpp  
 M  +1 -0      generators/spectre/generator_ghostview.cpp  
 M  +1 -0      generators/tiff/generator_tiff.cpp  
 M  +1 -0      generators/xps/generator_xps.cpp  
 M  +8 -0      part.cpp  


--- trunk/KDE/kdegraphics/okular/core/fileprinter.cpp #1134378:1134379
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by John Layt <john at layt.net>                       *
+ *   Copyright (C) 2007,2010 by John Layt <john at layt.net>                  *
  *                                                                         *
  *   FilePrinterPreview based on KPrintPreview (originally LGPL)           *
  *   Copyright (c) 2007 Alex Merry <huntedhacker at tiscali.co.uk>            *
@@ -145,7 +145,8 @@
     return ret;
 }
 
-QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage, const QList<int> &selectedPageList )
+QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage,
+                                  int currentPage, const QList<int> &selectedPageList )
 {
     if ( printer.printRange() == QPrinter::Selection) {
         return selectedPageList;
@@ -157,6 +158,11 @@
     if ( printer.printRange() == QPrinter::PageRange ) {
         startPage = printer.fromPage();
         endPage = printer.toPage();
+#if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
+    } else if ( printer.printRange() == QPrinter::CurrentPage) {
+        startPage = currentPage;
+        endPage = currentPage;
+#endif
     } else { //AllPages
         startPage = 1;
         endPage = lastPage;
--- trunk/KDE/kdegraphics/okular/core/fileprinter.h #1134378:1134379
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007 by John Layt <john at layt.net>                       *
+ *   Copyright (C) 2007, 2010 by John Layt <john at layt.net>                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -105,7 +105,8 @@
      * @param selectedPageList list of pages to use if Selection option is selected
      * @returns Returns list of pages to print
      */
-    static QList<int> pageList( QPrinter &printer, int lastPage, const QList<int> &selectedPageList );
+    static QList<int> pageList( QPrinter &printer, int lastPage,
+                                int currentPage, const QList<int> &selectedPageList );
 
     /** Return the range of pages selected by the user in the Print Dialog
      *
--- trunk/KDE/kdegraphics/okular/generators/comicbook/generator_comicbook.cpp #1134378:1134379
@@ -95,6 +95,7 @@
     QPainter p( &printer );
 
     QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
+                                                         document()->currentPage() + 1,
                                                          document()->bookmarkedPageList() );
 
     for ( int i = 0; i < pageList.count(); ++i ) {
--- trunk/KDE/kdegraphics/okular/generators/djvu/generator_djvu.cpp #1134378:1134379
@@ -209,6 +209,7 @@
 
     QMutexLocker locker( userMutex() );
     QList<int> pageList = Okular::FilePrinter::pageList( printer, m_djvu->pages().count(),
+                                                         document()->currentPage() + 1,
                                                          document()->bookmarkedPageList() );
 
     if ( m_djvu->exportAsPostScript( &tf, pageList ) )
--- trunk/KDE/kdegraphics/okular/generators/dvi/generator_dvi.cpp #1134378:1134379
@@ -553,6 +553,7 @@
 
     QList<int> pageList = Okular::FilePrinter::pageList( printer, 
                                  m_dviRenderer->totalPages(),
+                                 document()->currentPage() + 1,
                                  document()->bookmarkedPageList() );
     QString pages;
     QStringList printOptions;
--- trunk/KDE/kdegraphics/okular/generators/poppler/generator_pdf.cpp #1134378:1134379
@@ -894,6 +894,7 @@
 
     // Generate the list of pages to be printed as selected in the print dialog
     QList<int> pageList = Okular::FilePrinter::pageList( printer, pdfdoc->numPages(),
+                                                         document()->currentPage() + 1,
                                                          document()->bookmarkedPageList() );
 
     // TODO rotation
--- trunk/KDE/kdegraphics/okular/generators/spectre/generator_ghostview.cpp #1134378:1134379
@@ -111,6 +111,7 @@
     // Get list of pages to print
     QList<int> pageList = Okular::FilePrinter::pageList( printer,
                                                spectre_document_get_n_pages( m_internalDocument ),
+                                               document()->currentPage() + 1,
                                                document()->bookmarkedPageList() );
 
     // Default to Postscript export, but if printing to PDF use that instead
--- trunk/KDE/kdegraphics/okular/generators/tiff/generator_tiff.cpp #1134378:1134379
@@ -386,6 +386,7 @@
     QPainter p( &printer );
 
     QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
+                                                         document()->currentPage() + 1,
                                                          document()->bookmarkedPageList() );
 
     for ( tdir_t i = 0; i < pageList.count(); ++i )
--- trunk/KDE/kdegraphics/okular/generators/xps/generator_xps.cpp #1134378:1134379
@@ -2186,6 +2186,7 @@
 bool XpsGenerator::print( QPrinter &printer )
 {
     QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
+                                                         document()->currentPage() + 1,
                                                          document()->bookmarkedPageList() );
 
     QPainter painter( &printer );
--- trunk/KDE/kdegraphics/okular/part.cpp #1134378:1134379
@@ -1948,6 +1948,14 @@
             printDialog->setEnabledOptions( printDialog->enabledOptions() ^ QAbstractPrintDialog::PrintToFile );
         }
 
+#if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
+        // Enable the Current Page option in the dialog.
+        if ( m_document->pages() > 1 && currentPage() > 0 )
+        {
+            printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage );
+        }
+#endif
+
         if ( printDialog->exec() )
             doPrint( printer );
         delete printDialog;



More information about the Kde-bindings mailing list