[qet] [1596] Minor refactoring: added TitleBlockTemplateView::pastedCells(). |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1596
Author: xavier
Date: 2012-03-25 18:34:49 +0200 (Sun, 25 Mar 2012)
Log Message:
-----------
Minor refactoring: added TitleBlockTemplateView::pastedCells().
Modified Paths:
--------------
branches/0.3/sources/titleblock/templateview.cpp
branches/0.3/sources/titleblock/templateview.h
Modified: branches/0.3/sources/titleblock/templateview.cpp
===================================================================
--- branches/0.3/sources/titleblock/templateview.cpp 2012-03-25 06:17:15 UTC (rev 1595)
+++ branches/0.3/sources/titleblock/templateview.cpp 2012-03-25 16:34:49 UTC (rev 1596)
@@ -178,24 +178,25 @@
}
/**
- Import the cells described in the clipboard.
+ @return a list containing the pasted cells
*/
-void TitleBlockTemplateView::paste() {
+QList<TitleBlockCell> TitleBlockTemplateView::pastedCells() {
+ QList<TitleBlockCell> 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<TitleBlockCell> 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 @@
pasted_cells << cell;
}
}
+ return(pasted_cells);
+}
+
+/**
+ Import the cells described in the clipboard.
+*/
+void TitleBlockTemplateView::paste() {
+ QList<TitleBlockCell> pasted_cells = pastedCells();
// paste the first cell only
if (!pasted_cells.count()) return;
Modified: branches/0.3/sources/titleblock/templateview.h
===================================================================
--- branches/0.3/sources/titleblock/templateview.h 2012-03-25 06:17:15 UTC (rev 1595)
+++ branches/0.3/sources/titleblock/templateview.h 2012-03-25 16:34:49 UTC (rev 1596)
@@ -61,6 +61,7 @@
QList<TitleBlockCell *> cut();
QList<TitleBlockCell *> copy();
bool mayPaste();
+ QList<TitleBlockCell> pastedCells();
void paste();
void addColumnBefore();
void addRowBefore();