r17799 by fschmid - Allow dragging of items from the inline palette to the currently edited textframe.

scribus-commit scribus-commit at lists.scribus.net
Sat Oct 13 18:07:12 UTC 2012


Author: fschmid
Date: Sat Oct 13 18:07:12 2012
New Revision: 17799

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17799
Log:
Allow dragging of items from the inline palette to the currently edited textframe.

Modified:
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/ui/inlinepalette.cpp

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17799&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Sat Oct 13 18:07:12 2012
@@ -881,6 +881,40 @@
 		emit DocChanged();
 		update();
 		return;
+	}
+	else if (e->mimeData()->hasFormat("text/inline"))
+	{
+		if (((Doc->appMode == modeEditTable) || (Doc->appMode == modeEdit)) && (!Doc->m_Selection->isEmpty()))
+		{
+			PageItem *b = Doc->m_Selection->itemAt(0);
+			if (b->isTextFrame() || b->isTable())
+			{
+				e->acceptProposedAction();
+				activateWindow();
+				if (!m_ScMW->scriptIsRunning())
+					raise();
+				m_ScMW->newActWin(((ScribusWin*)(Doc->WinHan))->getSubWin());
+				updateContents();
+				QString patternVal = e->mimeData()->data("text/inline");
+				int id = patternVal.toInt();
+				PageItem_TextFrame *cItem;
+				if (Doc->appMode == modeEditTable)
+					cItem = b->asTable()->activeCell().textFrame();
+				else
+					cItem = b->asTextFrame();
+				if (cItem->HasSel)
+					cItem->deleteSelectedTextFromFrame();
+				cItem->invalidateLayout();
+				cItem->itemText.insertObject(id);
+				if (b->isTable())
+					b->asTable()->update();
+				else
+					b->update();
+				emit DocChanged();
+				update();
+				return;
+			}
+		}
 	}
 //	qDebug() << "ScribusView::contentsDropEvent" << e->mimeData()->formats() << url;
 	if (!url.isEmpty())

Modified: trunk/Scribus/scribus/ui/inlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17799&path=/trunk/Scribus/scribus/ui/inlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/inlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/inlinepalette.cpp Sat Oct 13 18:07:12 2012
@@ -80,7 +80,9 @@
  void InlineView::startDrag(Qt::DropActions supportedActions)
  {
 	QMimeData *mimeData = new QMimeData;
-	QByteArray data = currentItem()->text().toLocal8Bit();
+	int id = currentItem()->data(Qt::UserRole).toInt();
+	QByteArray data;
+	data.setNum(id);
 	mimeData->setData("text/inline", data);
 	QDrag *drag = new QDrag(this);
 	drag->setMimeData(mimeData);




More information about the scribus-commit mailing list