r17804 by fschmid - Allow dropping of objects to the inline palette.

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 14 08:21:34 UTC 2012


Author: fschmid
Date: Sun Oct 14 08:21:33 2012
New Revision: 17804

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17804
Log:
Allow dropping of objects to the inline palette.

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

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17804&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun Oct 14 08:21:33 2012
@@ -605,6 +605,7 @@
 	connect(inlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsInline"], SLOT(setChecked(bool)));
 	connect(inlinePalette, SIGNAL(startEdit(int)), this, SLOT(editInlineStart(int)));
 	connect(inlinePalette, SIGNAL(endEdit()), this, SLOT(editInlineEnd()));
+	connect(inlinePalette, SIGNAL(objectDropped(QString)), this, SLOT(PutToInline(QString)));
 	inlinePalette->installEventFilter(this);
 	inlinePalette->hide();
 	
@@ -10054,6 +10055,62 @@
 	}
 }
 
+void ScribusMainWindow::PutToInline(QString buffer)
+{
+	Selection tempSelection(*doc->m_Selection);
+	bool savedAlignGrid = doc->useRaster;
+	bool savedAlignGuides = doc->SnapGuides;
+	bool savedAlignElement = doc->SnapElement;
+	int ac = doc->Items->count();
+	bool isGroup = false;
+	double gx, gy, gh, gw;
+	FPoint minSize = doc->minCanvasCoordinate;
+	FPoint maxSize = doc->maxCanvasCoordinate;
+	doc->useRaster = false;
+	doc->SnapGuides = false;
+	doc->SnapElement = false;
+	undoManager->setUndoEnabled(false);
+	slotElemRead(buffer, 0, 0, false, true, doc, view);
+	doc->useRaster = savedAlignGrid;
+	doc->SnapGuides = savedAlignGuides;
+	doc->SnapElement = savedAlignElement;
+	doc->m_Selection->clear();
+	if (doc->Items->count() - ac > 1)
+		isGroup = true;
+	doc->m_Selection->delaySignalsOn();
+	for (int as = ac; as < doc->Items->count(); ++as)
+	{
+		doc->m_Selection->addItem(doc->Items->at(as));
+	}
+	if (isGroup)
+		doc->GroupCounter++;
+	doc->m_Selection->setGroupRect();
+	doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+	PageItem* currItem3 = doc->Items->at(ac);
+	currItem3->isEmbedded = true;
+	currItem3->setIsAnnotation(false);
+	currItem3->isBookmark = false;
+	currItem3->gXpos = currItem3->xPos() - gx;
+	currItem3->gYpos = currItem3->yPos() - gy;
+	currItem3->gWidth = gw;
+	currItem3->gHeight = gh;
+	doc->addToInlineFrames(currItem3);
+	int acc = doc->Items->count();
+	for (int as = ac; as < acc; ++as)
+	{
+		doc->Items->takeAt(ac);
+	}
+	doc->m_Selection->clear();
+	doc->m_Selection->delaySignalsOff();
+	*doc->m_Selection=tempSelection;
+	doc->minCanvasCoordinate = minSize;
+	doc->maxCanvasCoordinate = maxSize;
+	undoManager->setUndoEnabled(true);
+	inlinePalette->unsetDoc();
+	inlinePalette->setDoc(doc);
+	view->Deselect(false);
+}
+
 void ScribusMainWindow::PutToPatterns()
 {
 	int z;

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17804&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Sun Oct 14 08:21:33 2012
@@ -272,6 +272,7 @@
 	void updateActiveWindowCaption(const QString &newCaption);
 	void windowsMenuActivated(int id);
 	void PutScrap(int scID);
+	void PutToInline(QString buffer);
 	void PutToPatterns();
 	void changeLayer(int);
 	void showLayer();

Modified: trunk/Scribus/scribus/ui/inlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17804&path=/trunk/Scribus/scribus/ui/inlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/inlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/inlinepalette.cpp Sun Oct 14 08:21:33 2012
@@ -72,6 +72,11 @@
 		e->acceptProposedAction();
 		if (e->source() == this)
 			return;
+		QString text = e->mimeData()->text();
+		if ((text.startsWith("<SCRIBUSELEM")) || (text.startsWith("SCRIBUSELEMUTF8")))
+		{
+			emit objectDropped(text);
+		}
 	}
 	else
 		e->ignore();
@@ -105,6 +110,7 @@
 	languageChange();
 	connect(InlineViewWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(handleDoubleClick(QListWidgetItem *)));
 	connect(InlineViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleContextMenue(QPoint)));
+	connect(InlineViewWidget, SIGNAL(objectDropped(QString)), this, SIGNAL(objectDropped(QString)));
 }
 
 void InlinePalette::handleContextMenue(QPoint p)

Modified: trunk/Scribus/scribus/ui/inlinepalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17804&path=/trunk/Scribus/scribus/ui/inlinepalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/inlinepalette.h (original)
+++ trunk/Scribus/scribus/ui/inlinepalette.h Sun Oct 14 08:21:33 2012
@@ -60,6 +60,9 @@
 	void dropEvent(QDropEvent *e);
 	void startDrag(Qt::DropActions supportedActions);
 
+signals:
+	void objectDropped(QString);
+
 private:
 	ScListWidgetDelegate* delegate;
 };
@@ -92,6 +95,7 @@
 signals:
 	void startEdit(int);
 	void endEdit();
+	void objectDropped(QString);
 
 protected:
 	InlineView *InlineViewWidget;




More information about the scribus-commit mailing list