[Uml-devel] branches/work/soc-umbrello/umbrello
Andi Fischer
andi.fischer at hispeed.ch
Tue Nov 29 10:01:04 UTC 2011
SVN commit 1266318 by fischer:
Patch from Ralf Habacker: Print preview added.
M +32 -3 uml.cpp
M +3 -0 uml.h
--- branches/work/soc-umbrello/umbrello/uml.cpp #1266317:1266318
@@ -89,6 +89,7 @@
#include <QtGui/QStackedWidget>
#include <QtGui/QPrinter>
#include <QtGui/QPrintDialog>
+#include <QtGui/QPrintPreviewDialog>
#include <QtGui/QUndoView>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
@@ -226,13 +227,14 @@
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());
editRedo = m_pUndoStack->createRedoAction(actionCollection());
- disconnect( m_pUndoStack, SIGNAL( undoTextChanged(const QString& ) ),editUndo, 0 );
- disconnect( m_pUndoStack, SIGNAL( redoTextChanged(const QString& ) ),editRedo, 0 );
+ disconnect( m_pUndoStack, SIGNAL(undoTextChanged(QString)), editUndo, 0 );
+ disconnect( m_pUndoStack, SIGNAL(redoTextChanged(QString)), editRedo, 0 );
editCut = KStandardAction::cut(this, SLOT(slotEditCut()), actionCollection());
editCopy = KStandardAction::copy(this, SLOT(slotEditCopy()), actionCollection());
@@ -333,6 +335,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"));
@@ -678,7 +681,7 @@
*/
void UMLApp::initStatusBar()
{
- connect(m_doc, SIGNAL( sigWriteToStatusBar(const QString &) ), this, SLOT( slotStatusMsg(const QString &) ));
+ connect(m_doc, SIGNAL(sigWriteToStatusBar(QString)), this, SLOT(slotStatusMsg(QString)));
m_statusBarMessage = new QLabel(i18nc("init status bar", "Ready"));
statusBar()->addWidget(m_statusBarMessage);
@@ -1265,6 +1268,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()
@@ -1616,6 +1644,7 @@
void UMLApp::enablePrint(bool enable)
{
filePrint->setEnabled(enable);
+ printPreview->setEnabled(enable);
}
/**
--- branches/work/soc-umbrello/umbrello/uml.h #1266317:1266318
@@ -196,6 +196,8 @@
void slotFileSave();
bool slotFileSaveAs();
void slotFileClose();
+ void slotPrintPreview();
+ void slotPrintPreviewPaintRequested(QPrinter *printer);
void slotFilePrint();
void slotFileQuit();
void slotFileExportDocbook();
@@ -347,6 +349,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