mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
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
This commit is contained in:
@@ -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<TitleBlockCell> TitleBlockTemplateView::pastedCells() {
|
||||||
|
QList<TitleBlockCell> pasted_cells;
|
||||||
|
|
||||||
// retrieve the clipboard content and parse it as XML
|
// retrieve the clipboard content and parse it as XML
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
QDomDocument xml_import;
|
QDomDocument xml_import;
|
||||||
|
|
||||||
if (!xml_import.setContent(clipboard -> text().trimmed())) {
|
if (!xml_import.setContent(clipboard -> text().trimmed())) {
|
||||||
return;
|
return(pasted_cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure the XML document describes cells that can be pasted
|
// ensure the XML document describes cells that can be pasted
|
||||||
if (xml_import.documentElement().tagName() != "titleblocktemplate-partial") {
|
if (xml_import.documentElement().tagName() != "titleblocktemplate-partial") {
|
||||||
return;
|
return(pasted_cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load pasted cells
|
// load pasted cells
|
||||||
QList<TitleBlockCell> pasted_cells;
|
|
||||||
QDomElement paste_root = xml_import.documentElement();
|
QDomElement paste_root = xml_import.documentElement();
|
||||||
for (QDomElement e = paste_root.firstChildElement() ; !e.isNull() ; e = e.nextSiblingElement()) {
|
for (QDomElement e = paste_root.firstChildElement() ; !e.isNull() ; e = e.nextSiblingElement()) {
|
||||||
if (e.tagName() == "empty" || e.tagName() == "field" || e.tagName() == "logo") {
|
if (e.tagName() == "empty" || e.tagName() == "field" || e.tagName() == "logo") {
|
||||||
@@ -204,6 +205,14 @@ void TitleBlockTemplateView::paste() {
|
|||||||
pasted_cells << cell;
|
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
|
// paste the first cell only
|
||||||
if (!pasted_cells.count()) return;
|
if (!pasted_cells.count()) return;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class TitleBlockTemplateView : public QGraphicsView {
|
|||||||
QList<TitleBlockCell *> cut();
|
QList<TitleBlockCell *> cut();
|
||||||
QList<TitleBlockCell *> copy();
|
QList<TitleBlockCell *> copy();
|
||||||
bool mayPaste();
|
bool mayPaste();
|
||||||
|
QList<TitleBlockCell> pastedCells();
|
||||||
void paste();
|
void paste();
|
||||||
void addColumnBefore();
|
void addColumnBefore();
|
||||||
void addRowBefore();
|
void addRowBefore();
|
||||||
|
|||||||
Reference in New Issue
Block a user