From e31a8a375ee74f7e41531f1b8a5a79c1cf7e0b78 Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 25 Mar 2012 16:34:49 +0000 Subject: [PATCH] Minor refactoring: added TitleBlockTemplateView::pastedCells(). git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1596 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/titleblock/templateview.cpp | 19 ++++++++++++++----- sources/titleblock/templateview.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sources/titleblock/templateview.cpp b/sources/titleblock/templateview.cpp index 11ec727c2..e06998b02 100644 --- a/sources/titleblock/templateview.cpp +++ b/sources/titleblock/templateview.cpp @@ -178,24 +178,25 @@ bool TitleBlockTemplateView::mayPaste() { } /** - Import the cells described in the clipboard. + @return a list containing the pasted cells */ -void TitleBlockTemplateView::paste() { +QList TitleBlockTemplateView::pastedCells() { + QList pasted_cells; + // retrieve the clipboard content and parse it as XML QClipboard *clipboard = QApplication::clipboard(); QDomDocument xml_import; if (!xml_import.setContent(clipboard -> text().trimmed())) { - return; + return(pasted_cells); } // ensure the XML document describes cells that can be pasted if (xml_import.documentElement().tagName() != "titleblocktemplate-partial") { - return; + return(pasted_cells); } // load pasted cells - QList pasted_cells; QDomElement paste_root = xml_import.documentElement(); for (QDomElement e = paste_root.firstChildElement() ; !e.isNull() ; e = e.nextSiblingElement()) { if (e.tagName() == "empty" || e.tagName() == "field" || e.tagName() == "logo") { @@ -204,6 +205,14 @@ void TitleBlockTemplateView::paste() { pasted_cells << cell; } } + return(pasted_cells); +} + +/** + Import the cells described in the clipboard. +*/ +void TitleBlockTemplateView::paste() { + QList pasted_cells = pastedCells(); // paste the first cell only if (!pasted_cells.count()) return; diff --git a/sources/titleblock/templateview.h b/sources/titleblock/templateview.h index a6cef31e9..130402cbb 100644 --- a/sources/titleblock/templateview.h +++ b/sources/titleblock/templateview.h @@ -61,6 +61,7 @@ class TitleBlockTemplateView : public QGraphicsView { QList cut(); QList copy(); bool mayPaste(); + QList pastedCells(); void paste(); void addColumnBefore(); void addRowBefore();