[Uml-devel] branches/KDE/4.7/kdesdk/umbrello/umbrello

Ralf Habacker ralf.habacker at gmail.com
Tue Nov 29 11:49:38 UTC 2011


SVN commit 1266327 by habacker:

backported from trunk r1266322: print preview added

 M  +29 -0     uml.cpp  
 M  +3 -0      uml.h  


--- branches/KDE/4.7/kdesdk/umbrello/umbrello/uml.cpp #1266326:1266327
@@ -88,6 +88,7 @@
 #include <QtGui/QStackedWidget>
 #include <QtGui/QPrinter>
 #include <QtGui/QPrintDialog>
+#include <QtGui/QPrintPreviewDialog>
 #include <QtGui/QUndoView>
 
 /** Static pointer, holding the last created instance. */
@@ -221,6 +222,7 @@
     QAction* fileSaveAs = KStandardAction::saveAs(this, SLOT(slotFileSaveAs()), actionCollection());
     QAction* fileClose = KStandardAction::close(this, SLOT(slotFileClose()), actionCollection());
     filePrint = KStandardAction::print(this, SLOT(slotFilePrint()), actionCollection());
+    printPreview = KStandardAction::printPreview(this, SLOT(slotPrintPreview()), actionCollection());
     QAction* fileQuit = KStandardAction::quit(this, SLOT(slotFileQuit()), actionCollection());
 
     editUndo = m_pUndoStack->createUndoAction(actionCollection());
@@ -323,6 +325,7 @@
     fileSaveAs->setToolTip(i18n("Saves the document as..."));
     fileClose->setToolTip(i18n("Closes the document"));
     filePrint->setToolTip(i18n("Prints out the document"));
+    printPreview->setToolTip(i18n("Print Preview of the document"));
     fileQuit->setToolTip(i18n("Quits the application"));
     fileExportDocbook->setToolTip(i18n("Exports the model to the docbook format"));
     fileExportXhtml->setToolTip(i18n("Exports the model to the XHTML format"));
@@ -1163,6 +1166,31 @@
 }
 
 /**
+ * Print preview
+ */
+void UMLApp::slotPrintPreview()
+{
+    QPrinter printer;
+    printer.setFullPage(true);
+
+    slotStatusMsg(i18n("Print Preview..."));
+
+    QPrintPreviewDialog *preview = new QPrintPreviewDialog(&printer,this);
+    connect(preview, SIGNAL(paintRequested(QPrinter *)), this, SLOT(slotPrintPreviewPaintRequested(QPrinter *)));
+    preview->exec();
+}
+
+/**
+ * Print preview painting slot
+ */
+void UMLApp::slotPrintPreviewPaintRequested(QPrinter *printer)
+{
+    DiagramPrintPage * selectPage = new DiagramPrintPage(0, m_doc);
+    m_doc->print(printer, selectPage);
+    delete selectPage;
+}
+
+/**
  * Print the current file.
  */
 void UMLApp::slotFilePrint()
@@ -1506,6 +1534,7 @@
 void UMLApp::enablePrint(bool enable)
 {
     filePrint->setEnabled(enable);
+    printPreview->setEnabled(enable);
 }
 
 /**
--- branches/KDE/4.7/kdesdk/umbrello/umbrello/uml.h #1266326:1266327
@@ -192,6 +192,8 @@
     void slotFileSave();
     bool slotFileSaveAs();
     void slotFileClose();
+    void slotPrintPreview();
+    void slotPrintPreviewPaintRequested(QPrinter *printer);
     void slotFilePrint();
     void slotFileQuit();
     void slotFileExportDocbook();
@@ -340,6 +342,7 @@
 
     // KAction pointers to enable/disable actions
     KRecentFilesAction* fileOpenRecent;
+    QAction* printPreview;
     QAction* filePrint;
     QAction* editCut;
     QAction* editCopy;




More information about the umbrello-devel mailing list