mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
handle drag and drop of text (html work to)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2585 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -232,6 +232,8 @@ void DiagramView::dragEnterEvent(QDragEnterEvent *e) {
|
|||||||
e -> acceptProposedAction();
|
e -> acceptProposedAction();
|
||||||
} else if (e -> mimeData() -> hasFormat("application/x-qet-titleblock-uri")) {
|
} else if (e -> mimeData() -> hasFormat("application/x-qet-titleblock-uri")) {
|
||||||
e -> acceptProposedAction();
|
e -> acceptProposedAction();
|
||||||
|
} else if (e -> mimeData() -> hasText()) {
|
||||||
|
e -> acceptProposedAction();
|
||||||
} else {
|
} else {
|
||||||
e -> ignore();
|
e -> ignore();
|
||||||
}
|
}
|
||||||
@@ -264,6 +266,8 @@ void DiagramView::dropEvent(QDropEvent *e) {
|
|||||||
handleElementDrop(e);
|
handleElementDrop(e);
|
||||||
} else if (e -> mimeData() -> hasFormat("application/x-qet-titleblock-uri")) {
|
} else if (e -> mimeData() -> hasFormat("application/x-qet-titleblock-uri")) {
|
||||||
handleTitleBlockDrop(e);
|
handleTitleBlockDrop(e);
|
||||||
|
} else if (e -> mimeData() -> hasText()) {
|
||||||
|
handleTextDrop(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,6 +304,18 @@ void DiagramView::handleTitleBlockDrop(QDropEvent *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
Set the Diagram in visualisation mode
|
||||||
*/
|
*/
|
||||||
@@ -1311,11 +1327,14 @@ DiagramImageItem *DiagramView::addDiagramImageAtPos(const QPointF &pos) {
|
|||||||
@param pos Position du champ de texte ajoute
|
@param pos Position du champ de texte ajoute
|
||||||
@return le 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);
|
if (!isInteractive() || scene -> isReadOnly()) return(0);
|
||||||
|
|
||||||
// cree un nouveau champ de texte
|
// 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
|
// le place a la position pos en gerant l'annulation
|
||||||
scene -> undoStack().push(new AddTextCommand(scene, iti, pos));
|
scene -> undoStack().push(new AddTextCommand(scene, iti, pos));
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class DiagramView : public QGraphicsView {
|
|||||||
void editText();
|
void editText();
|
||||||
void addImage();
|
void addImage();
|
||||||
void editImage();
|
void editImage();
|
||||||
IndependentTextItem *addDiagramTextAtPos(const QPointF &);
|
IndependentTextItem *addDiagramTextAtPos(const QPointF &, const QString text = 0);
|
||||||
DiagramImageItem *addDiagramImageAtPos(const QPointF &);
|
DiagramImageItem *addDiagramImageAtPos(const QPointF &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -102,6 +102,7 @@ class DiagramView : public QGraphicsView {
|
|||||||
void dropEvent(QDropEvent *);
|
void dropEvent(QDropEvent *);
|
||||||
void handleElementDrop(QDropEvent *);
|
void handleElementDrop(QDropEvent *);
|
||||||
void handleTitleBlockDrop(QDropEvent *);
|
void handleTitleBlockDrop(QDropEvent *);
|
||||||
|
void handleTextDrop(QDropEvent *);
|
||||||
QRectF viewedSceneRect() const;
|
QRectF viewedSceneRect() const;
|
||||||
bool mustIntegrateElement(const ElementsLocation &) const;
|
bool mustIntegrateElement(const ElementsLocation &) const;
|
||||||
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const;
|
bool mustIntegrateTitleBlockTemplate(const TitleBlockTemplateLocation &) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user