[qet] [2585] handle drag and drop of text (html work to) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 2585
Author: blacksun
Date: 2013-10-26 13:46:59 +0200 (Sat, 26 Oct 2013)
Log Message:
-----------
handle drag and drop of text (html work to)
Modified Paths:
--------------
trunk/sources/diagramview.cpp
trunk/sources/diagramview.h
Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp 2013-10-25 04:55:04 UTC (rev 2584)
+++ trunk/sources/diagramview.cpp 2013-10-26 11:46:59 UTC (rev 2585)
@@ -232,6 +232,8 @@
e -> acceptProposedAction();
} else if (e -> mimeData() -> hasFormat("application/x-qet-titleblock-uri")) {
e -> acceptProposedAction();
+ } else if (e -> mimeData() -> hasText()) {
+ e -> acceptProposedAction();
} else {
e -> ignore();
}
@@ -264,6 +266,8 @@
handleElementDrop(e);
} else if (e -> mimeData() -> hasFormat("application/x-qet-titleblock-uri")) {
handleTitleBlockDrop(e);
+ } else if (e -> mimeData() -> hasText()) {
+ handleTextDrop(e);
}
}
@@ -301,6 +305,18 @@
}
/**
+ * @brief DiagramView::handleTextDrop
+ *handle the drop of text, html markup are automatically detected.
+ * @param e the QDropEvent describing the current drag'n drop
+ */
+void DiagramView::handleTextDrop(QDropEvent *e) {
+ if (e -> mimeData() -> hasText()) {
+ if (e -> mimeData() -> hasHtml()) addDiagramTextAtPos(e->pos()) -> setHtml(e -> mimeData() -> text());
+ else addDiagramTextAtPos(e -> pos(), e -> mimeData() -> text());
+ }
+}
+
+/**
Set the Diagram in visualisation mode
*/
void DiagramView::setVisualisationMode() {
@@ -1311,11 +1327,14 @@
@param pos Position du champ de texte ajoute
@return le champ de texte ajoute
*/
-IndependentTextItem *DiagramView::addDiagramTextAtPos(const QPointF &pos) {
+IndependentTextItem *DiagramView::addDiagramTextAtPos(const QPointF &pos, const QString text) {
if (!isInteractive() || scene -> isReadOnly()) return(0);
// cree un nouveau champ de texte
- IndependentTextItem *iti = new IndependentTextItem("_");
+ IndependentTextItem *iti;
+ if (text.isEmpty()) {
+ iti = new IndependentTextItem("_");
+ } else iti = new IndependentTextItem(text);
// le place a la position pos en gerant l'annulation
scene -> undoStack().push(new AddTextCommand(scene, iti, pos));
Modified: trunk/sources/diagramview.h
===================================================================
--- trunk/sources/diagramview.h 2013-10-25 04:55:04 UTC (rev 2584)
+++ trunk/sources/diagramview.h 2013-10-26 11:46:59 UTC (rev 2585)
@@ -76,7 +76,7 @@
void editText();
void addImage();
void editImage();
- IndependentTextItem *addDiagramTextAtPos(const QPointF &);
+ IndependentTextItem *addDiagramTextAtPos(const QPointF &, const QString text = 0);
DiagramImageItem *addDiagramImageAtPos(const QPointF &);
protected:
@@ -102,6 +102,7 @@
void dropEvent(QDropEvent *);
void handleElementDrop(QDropEvent *);
void handleTitleBlockDrop(QDropEvent *);
+ void handleTextDrop(QDropEvent *);
QRectF viewedSceneRect() const;
bool mustIntegrateElement(const ElementsLocation &) const;
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const;