[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeutils/khexedit
From:       John Layt <john () layt ! net>
Date:       2007-10-13 20:59:21
Message-ID: 1192309161.580924.15431.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 724919 by jlayt:

Port from KPrinter to QPrinter, remove dependency on KDE4_KDEPRINT_LIBS


 M  +1 -1      CMakeLists.txt  
 M  +26 -19    hexeditorwidget.cc  
 M  +1 -1      hexprinter.cc  
 M  +2 -2      hexprinter.h  
 M  +28 -18    printdialogpage.cc  
 M  +14 -5     printdialogpage.h  


--- trunk/KDE/kdeutils/khexedit/CMakeLists.txt #724918:724919
@@ -39,7 +39,7 @@
 
 kde4_add_executable(khexedit ${khexedit_SRCS})
 
-target_link_libraries(khexedit   ${KDE4_KDEPRINT_LIBS} ${KDE4_KDE3SUPPORT_LIBS})
+target_link_libraries(khexedit   ${KDE4_KIO_LIBS} ${KDE4_KDE3SUPPORT_LIBS})
 
 install(TARGETS khexedit  DESTINATION ${BIN_INSTALL_DIR} )
 
--- trunk/KDE/kdeutils/khexedit/hexeditorwidget.cc #724918:724919
@@ -25,6 +25,10 @@
 
 #undef Unsorted
 
+#include <QtGui/QPrinter>
+#include <QtGui/QPrintDialog>
+#include <kdeprintdialog.h>
+
 #include <kfiledialog.h>
 #include <kglobalsettings.h>
 #include <kio/netaccess.h>
@@ -1030,30 +1034,32 @@
 {
   CHexPrinter prt;
 
-  prt.addDialogPage( new LayoutDialogPage() );
-
-  prt.setPageSelection( KPrinter::SystemSide );
+  //Not supported by Qt?
+  //prt.setPageSelection( QPrinter::SystemSide );
   prt.setFullPage( true ); // I use my own marings
 
+  LayoutDialogPage* dialogPage = new LayoutDialogPage();
+  QPrintDialog *printDialog = KdePrint::createPrintDialog(&prt, QList<QWidget*>() << \
dialogPage, topLevelWidget());  // FIXME: Make a better header for the printingdialog
-  if (prt.setup(topLevelWidget(), i18n("Print Hex-Document")))
+  printDialog->setWindowTitle(i18n("Print Hex-Document"));
+  if (printDialog->exec())
   {
-     prt.setTopMarginMM( prt.option("kde-khexedit-topmarginmm").toInt() );
-     prt.setBottomMarginMM( prt.option("kde-khexedit-bottommarginmm").toInt() );
-     prt.setLeftMarginMM( prt.option("kde-khexedit-leftmarginmm").toInt() );
-     prt.setRightMarginMM( prt.option("kde-khexedit-rightmarginmm").toInt() );
+     prt.setTopMarginMM( dialogPage->printTopMarginMm() );
+     prt.setBottomMarginMM( dialogPage->printBottomMarginMm() );
+     prt.setLeftMarginMM( dialogPage->printLeftMarginMm() );
+     prt.setRightMarginMM( dialogPage->printRightMarginMm() );
 
-     prt.setPageHeader( (prt.option("kde-khexedit-headercheck") == "true"),
-			  prt.option("kde-khexedit-headercombo0").toInt(),
-			  prt.option("kde-khexedit-headercombo1").toInt(),
-			  prt.option("kde-khexedit-headercombo2").toInt(),
-			  prt.option("kde-khexedit-headercombo3").toInt() );
+     prt.setPageHeader( dialogPage->printHeader(),
+			  dialogPage->printHeaderCombo(0),
+			  dialogPage->printHeaderCombo(1),
+			  dialogPage->printHeaderCombo(2),
+			  dialogPage->printHeaderCombo(3) );
 
-     prt.setPageFooter( (prt.option("kde-khexedit-footercheck") == "true"),
-			  prt.option("kde-khexedit-footercombo0").toInt(),
-			  prt.option("kde-khexedit-footercombo1").toInt(),
-			  prt.option("kde-khexedit-footercombo2").toInt(),
-			  prt.option("kde-khexedit-footercombo3").toInt() );
+     prt.setPageFooter( dialogPage->printFooter(),
+			  dialogPage->printFooterCombo(0),
+			  dialogPage->printFooterCombo(1),
+			  dialogPage->printFooterCombo(2),
+			  dialogPage->printFooterCombo(3) );
 
      printPostscript(prt);
   }
@@ -1101,7 +1107,8 @@
   {
     uint numPage = mHexView->numPage( printer );
     printer.setMinMax( 1, numPage );
-    uint numPageSelected = printer.pageList().count();
+    //uint numPageSelected = printer.pageList().count();
+    uint numPageSelected = printer.toPage() - printer.fromPage();
 
     if( numPageSelected > mDisplayState.misc.thresholdValue )
     {
--- trunk/KDE/kdeutils/khexedit/hexprinter.cc #724918:724919
@@ -23,7 +23,7 @@
 
 
 CHexPrinter::CHexPrinter( void )
-  : KPrinter()
+  : QPrinter()
 {
 }
 
--- trunk/KDE/kdeutils/khexedit/hexprinter.h #724918:724919
@@ -21,8 +21,8 @@
 #ifndef _HEX_PRINTER_H_
 #define _HEX_PRINTER_H_
 
-#include <kprinter.h>
 #include <q3paintdevicemetrics.h>
+#include <QtGui/QPrinter>
 
 struct SPageSize
 {
@@ -64,7 +64,7 @@
 
 
 
-class CHexPrinter : public KPrinter
+class CHexPrinter : public QPrinter
 {
   public:
     CHexPrinter( void );
--- trunk/KDE/kdeutils/khexedit/printdialogpage.cc #724918:724919
@@ -32,10 +32,10 @@
 
 
 LayoutDialogPage::LayoutDialogPage( QWidget *parent )
- : KPrintDialogPage( parent )
+ : QWidget( parent )
 {
   mConfig = 0;
-  setTitle( i18n( "Page Layout" ) );
+  setWindowTitle( i18n( "Page Layout" ) );
   setupLayoutPage();
 
   readConfiguration();
@@ -360,26 +360,36 @@
   }
 }
 
+int LayoutDialogPage::printTopMarginMm() {
+   return mLayout.marginSpin[0]->value();
+}
 
-void LayoutDialogPage::getOptions( QMap<QString,QString>& opts, bool /*incldef*/ )
-{
-   opts[ "kde-khexedit-topmarginmm" ]    = QString::number( \
                mLayout.marginSpin[0]->value() );
-   opts[ "kde-khexedit-bottommarginmm" ] = QString::number( \
                mLayout.marginSpin[1]->value() );
-   opts[ "kde-khexedit-leftmarginmm" ]   = QString::number( \
                mLayout.marginSpin[2]->value() );
-   opts[ "kde-khexedit-rightmarginmm" ]  = QString::number( \
mLayout.marginSpin[3]->value() ); +int LayoutDialogPage::printBottomMarginMm() {
+   return mLayout.marginSpin[1]->value();
+}
 
-   opts[ "kde-khexedit-headercheck" ]  = (mLayout.headerCheck->isChecked() ? "true" \
                : "false");
-   opts[ "kde-khexedit-headercombo0" ] = QString::number( \
                mLayout.headerCombo[0]->currentIndex() );
-   opts[ "kde-khexedit-headercombo1" ] = QString::number( \
                mLayout.headerCombo[1]->currentIndex() );
-   opts[ "kde-khexedit-headercombo2" ] = QString::number( \
                mLayout.headerCombo[2]->currentIndex() );
-   opts[ "kde-khexedit-headercombo3" ] = QString::number( \
mLayout.headerCombo[3]->currentIndex() ); +int LayoutDialogPage::printLeftMarginMm() \
{ +   return mLayout.marginSpin[2]->value();
+}
 
-   opts[ "kde-khexedit-footercheck" ]  = (mLayout.footerCheck->isChecked() ? "true" \
                : "false");
-   opts[ "kde-khexedit-footercombo0" ] = QString::number( \
                mLayout.footerCombo[0]->currentIndex() );
-   opts[ "kde-khexedit-footercombo1" ] = QString::number( \
                mLayout.footerCombo[1]->currentIndex() );
-   opts[ "kde-khexedit-footercombo2" ] = QString::number( \
                mLayout.footerCombo[2]->currentIndex() );
-   opts[ "kde-khexedit-footercombo3" ] = QString::number( \
mLayout.footerCombo[3]->currentIndex() ); +int LayoutDialogPage::printRightMarginMm() \
{ +   return mLayout.marginSpin[3]->value();
 }
 
+bool LayoutDialogPage::printHeader() {
+   return mLayout.headerCheck->isChecked();
+}
 
+int LayoutDialogPage::printHeaderCombo(int sel) {
+   return mLayout.headerCombo[sel]->currentIndex();
+}
+
+bool LayoutDialogPage::printFooter() {
+   return mLayout.footerCheck->isChecked();
+}
+
+int LayoutDialogPage::printFooterCombo(int sel) {
+   return mLayout.footerCombo[sel]->currentIndex();
+}
+
 #include "printdialogpage.moc"
--- trunk/KDE/kdeutils/khexedit/printdialogpage.h #724918:724919
@@ -1,5 +1,3 @@
-//Added by qt3to4:
-#include <QLabel>
 /*
  *   khexedit - Versatile hex editor
  *   Copyright (C) 1999  Espen Sand, espensa@online.no
@@ -24,15 +22,17 @@
 #ifndef _PRINT_DIALOG_PAGE_H_
 #define _PRINT_DIALOG_PAGE_H_
 
+//Added by qt3to4:
+#include <QLabel>
+
 class QCheckBox;
 class KComboBox;
 class QLabel;
 class QSpinBox;
 
-#include <kdeprint/kprintdialogpage.h>
 #include <kconfig.h>
 
-class LayoutDialogPage : public KPrintDialogPage
+class LayoutDialogPage : public QWidget
 {
  Q_OBJECT
 
@@ -40,8 +40,17 @@
     LayoutDialogPage( QWidget *parent = 0 );
     ~LayoutDialogPage( void );
 
-    void getOptions( QMap<QString,QString>& opts, bool incldef = false );
+    int printTopMarginMm();
+    int printBottomMarginMm();
+    int printLeftMarginMm();
+    int printRightMarginMm();
 
+    bool printHeader();
+    int printHeaderCombo(int sel);
+
+    bool printFooter();
+    int printFooterCombo(int sel);
+
  private slots:
    void slotDrawHeader( bool state );
    void slotDrawFooter( bool state );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic