[qet] [1556] Title block template editor: implemented copy operation. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1556
Author: xavier
Date: 2012-03-11 17:06:22 +0100 (Sun, 11 Mar 2012)
Log Message:
-----------
Title block template editor: implemented copy operation.
Modified Paths:
--------------
branches/0.3/sources/titleblock/qettemplateeditor.cpp
branches/0.3/sources/titleblock/qettemplateeditor.h
branches/0.3/sources/titleblock/templateview.cpp
branches/0.3/sources/titleblock/templateview.h
branches/0.3/sources/titleblocktemplate.cpp
branches/0.3/sources/titleblocktemplate.h
Modified: branches/0.3/sources/titleblock/qettemplateeditor.cpp
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-03-11 13:49:35 UTC (rev 1555)
+++ branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-03-11 16:06:22 UTC (rev 1556)
@@ -300,6 +300,9 @@
quit_ = new QAction(QET::Icons::ApplicationExit, tr("&Quitter", "menu entry"), this);
undo_ = undo_stack_ -> createUndoAction(this);
redo_ = undo_stack_ -> createRedoAction(this);
+ cut_ = new QAction(QET::Icons::EditCut, tr("Co&uper", "menu entry"), this);
+ copy_ = new QAction(QET::Icons::EditCopy, tr("Cop&ier", "menu entry"), this);
+ paste_ = new QAction(QET::Icons::EditPaste, tr("C&oller", "menu entry"), this);
edit_info_ = new QAction(QET::Icons::UserInformations, tr("\311diter les informations compl\351mentaires", "menu entry"), this);
zoom_in_ = new QAction(QET::Icons::ZoomIn, tr("Zoom avant", "menu entry"), this);
zoom_out_ = new QAction(QET::Icons::ZoomOut, tr("Zoom arri\350re", "menu entry"), this);
@@ -319,6 +322,9 @@
quit_ -> setShortcut(QKeySequence(tr("Ctrl+Q", "shortcut to quit")));
undo_ -> setShortcut(QKeySequence::Undo);
redo_ -> setShortcut(QKeySequence::Redo);
+ cut_ -> setShortcut(QKeySequence::Cut);
+ copy_ -> setShortcut(QKeySequence::Copy);
+ paste_ -> setShortcut(QKeySequence::Paste);
edit_info_ -> setShortcut(QKeySequence(tr("Ctrl+Y", "shortcut to edit extra information")));
merge_cells_ -> setShortcut(QKeySequence(tr("Ctrl+K", "shortcut to merge cells")));
split_cell_ -> setShortcut(QKeySequence(tr("Ctrl+J", "shortcut to split merged cell")));
@@ -334,6 +340,9 @@
connect(save_as_, SIGNAL(triggered()), this, SLOT(saveAs()));
connect(save_as_file_, SIGNAL(triggered()), this, SLOT(saveAsFile()));
connect(quit_, SIGNAL(triggered()), this, SLOT(quit()));
+ connect(cut_, SIGNAL(triggered()), template_edition_area_view_, SLOT(cut()));
+ connect(copy_, SIGNAL(triggered()), template_edition_area_view_, SLOT(copy()));
+ connect(paste_, SIGNAL(triggered()), template_edition_area_view_, SLOT(paste()));
connect(zoom_in_, SIGNAL(triggered()), template_edition_area_view_, SLOT(zoomIn()));
connect(zoom_out_, SIGNAL(triggered()), template_edition_area_view_, SLOT(zoomOut()));
connect(zoom_fit_, SIGNAL(triggered()), template_edition_area_view_, SLOT(zoomFit()));
@@ -363,7 +372,10 @@
edit_menu_ -> addAction(undo_);
edit_menu_ -> addAction(redo_);
edit_menu_ -> addSeparator();
-
+ edit_menu_ -> addAction(cut_);
+ edit_menu_ -> addAction(copy_);
+ edit_menu_ -> addAction(paste_);
+ edit_menu_ -> addSeparator();
edit_menu_ -> addAction(merge_cells_);
edit_menu_ -> addAction(split_cell_);
edit_menu_ -> addAction(edit_info_);
Modified: branches/0.3/sources/titleblock/qettemplateeditor.h
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.h 2012-03-11 13:49:35 UTC (rev 1555)
+++ branches/0.3/sources/titleblock/qettemplateeditor.h 2012-03-11 16:06:22 UTC (rev 1556)
@@ -49,7 +49,7 @@
QMenu *file_menu_, *edit_menu_,/* *paste_from_menu_, */*display_menu_,/* *tools_menu_*/;
/// actions
QAction *new_, *open_, *open_from_file_, *save_, *save_as_, *save_as_file_, *quit_;
- QAction *undo_, *redo_, *edit_info_, *merge_cells_, *split_cell_;
+ QAction *undo_, *redo_, *cut_, *copy_, *paste_, *edit_info_, *merge_cells_, *split_cell_;
QAction *zoom_in_, *zoom_out_, *zoom_fit_, *zoom_reset_;
/// Location of the currently edited template
TitleBlockTemplateLocation location_;
Modified: branches/0.3/sources/titleblock/templateview.cpp
===================================================================
--- branches/0.3/sources/titleblock/templateview.cpp 2012-03-11 13:49:35 UTC (rev 1555)
+++ branches/0.3/sources/titleblock/templateview.cpp 2012-03-11 16:06:22 UTC (rev 1556)
@@ -131,6 +131,38 @@
}
/**
+ Export currently selected cells to the clipboard before setting them as
+ empty.
+*/
+void TitleBlockTemplateView::cut() {
+ /// TODO
+}
+
+/**
+ Export currently selected cells to the clipboard.
+*/
+void TitleBlockTemplateView::copy() {
+ if (!tbtemplate_) return;
+
+ QDomDocument xml_export;
+ QDomElement tbtpartial = xml_export.createElement("titleblocktemplate-partial");
+ xml_export.appendChild(tbtpartial);
+ foreach (TitleBlockCell *cell, selectedCells()) {
+ tbtemplate_ -> exportCellToXml(cell, tbtpartial);
+ }
+
+ QClipboard *clipboard = QApplication::clipboard();
+ clipboard -> setText(xml_export.toString());
+}
+
+/**
+ Import the cells described in the clipboard.
+*/
+void TitleBlockTemplateView::paste() {
+ /// TODO
+}
+
+/**
Add a column right before the last index selected when calling the context
menu.
*/
Modified: branches/0.3/sources/titleblock/templateview.h
===================================================================
--- branches/0.3/sources/titleblock/templateview.h 2012-03-11 13:49:35 UTC (rev 1555)
+++ branches/0.3/sources/titleblock/templateview.h 2012-03-11 16:06:22 UTC (rev 1556)
@@ -58,6 +58,9 @@
void zoomOut();
void zoomFit();
void zoomReset();
+ void cut();
+ void copy();
+ void paste();
void addColumnBefore();
void addRowBefore();
void addColumnAfter();
Modified: branches/0.3/sources/titleblocktemplate.cpp
===================================================================
--- branches/0.3/sources/titleblocktemplate.cpp 2012-03-11 13:49:35 UTC (rev 1555)
+++ branches/0.3/sources/titleblocktemplate.cpp 2012-03-11 16:06:22 UTC (rev 1556)
@@ -166,6 +166,14 @@
}
/**
+ @param xml_element Parent XML element to be used when exporting \a cell
+ @param cell Cell to export
+*/
+void TitleBlockTemplate::exportCellToXml(TitleBlockCell *cell, QDomElement &xml_element) const {
+ saveCell(cell, xml_element, true);
+}
+
+/**
@return a deep copy of the current title block template (i.e. title block
cells are duplicated too and associated with their parent template).
*/
@@ -552,11 +560,14 @@
Export a specific cell as XML
@param cell Cell to be exported as XML
@param xml_element XML element under which the \<cell\> element will be attached
+ @param save_empty If true, the cell will be saved even if it is an empty one
*/
-void TitleBlockTemplate::saveCell(TitleBlockCell *cell, QDomElement &xml_element) const {
- if (!cell || cell -> cell_type == TitleBlockCell::EmptyCell) return;
+void TitleBlockTemplate::saveCell(TitleBlockCell *cell, QDomElement &xml_element, bool save_empty) const {
+ if (!cell) return;
if (cell -> spanner_cell) return;
+ if (!save_empty && cell -> cell_type == TitleBlockCell::EmptyCell) return;
+
QDomElement cell_elmt = xml_element.ownerDocument().createElement("cell");
cell_elmt.setAttribute("name", cell -> value_name);
cell_elmt.setAttribute("row", cell -> num_row);
@@ -564,7 +575,9 @@
if (cell -> row_span) cell_elmt.setAttribute("rowspan", cell -> row_span);
if (cell -> col_span) cell_elmt.setAttribute("colspan", cell -> col_span);
- if (cell -> type() == TitleBlockCell::LogoCell) {
+ if (cell -> type() == TitleBlockCell::EmptyCell) {
+ cell_elmt.setTagName("empty");
+ } else if (cell -> type() == TitleBlockCell::LogoCell) {
cell_elmt.setTagName("logo");
cell_elmt.setAttribute("resource", cell -> logo_reference);
} else {
Modified: branches/0.3/sources/titleblocktemplate.h
===================================================================
--- branches/0.3/sources/titleblocktemplate.h 2012-03-11 13:49:35 UTC (rev 1555)
+++ branches/0.3/sources/titleblocktemplate.h 2012-03-11 16:06:22 UTC (rev 1556)
@@ -49,6 +49,7 @@
bool loadFromXmlElement(const QDomElement &);
bool saveToXmlFile(const QString &);
bool saveToXmlElement(QDomElement &) const;
+ void exportCellToXml(TitleBlockCell *,QDomElement &) const;
TitleBlockTemplate *clone() const;
QString name() const;
QString information() const;
@@ -108,7 +109,7 @@
void saveLogo(const QString &, QDomElement &) const;
void saveGrid(QDomElement &) const;
void saveCells(QDomElement &) const;
- void saveCell(TitleBlockCell *, QDomElement &) const;
+ void saveCell(TitleBlockCell *, QDomElement &, bool = false) const;
QList<TitleBlockCell *> createCellsList(int);
private: