r20445 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Mon Oct 5 12:11:16 UTC 2015
Author: jghali
Date: Mon Oct 5 12:11:16 2015
New Revision: 20445
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20445
Log:
#13393: Edit > Duplicate changes relative levels of selected items
Modified:
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribusdoc.cpp
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20445&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Mon Oct 5 12:11:16 2015
@@ -6362,17 +6362,31 @@
doc->SnapGrid = false;
doc->SnapGuides = false;
doc->SnapElement = false;
- slotEditCopy();
- view->Deselect(true);
+
UndoTransaction trans;
if (UndoManager::undoEnabled())
trans = undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Duplicate,"",Um::IMultipleDuplicate);
- slotEditPaste();
- for (int i=0; i<doc->m_Selection->count(); ++i)
- {
- doc->m_Selection->itemAt(i)->setLocked(false);
- doc->MoveItem(doc->opToolPrefs().dispX, doc->opToolPrefs().dispY, doc->m_Selection->itemAt(i));
- }
+
+ ItemMultipleDuplicateData mdData;
+ memset(&mdData, 0, sizeof(mdData));
+ mdData.type = 0;
+ mdData.copyCount = 1;
+ mdData.copyShiftOrGap = 0;
+ mdData.copyShiftGapH = doc->opToolPrefs().dispX * doc->unitRatio();
+ mdData.copyShiftGapV = doc->opToolPrefs().dispY * doc->unitRatio();
+
+ int oldItemCount = doc->Items->count();
+ doc->itemSelection_MultipleDuplicate(mdData);
+
+ doc->m_Selection->blockSignals(true);
+ view->Deselect(true);
+ for (int i = oldItemCount; i < doc->Items->count(); ++i)
+ {
+ PageItem* item = doc->Items->at(i);
+ doc->m_Selection->addItem(item);
+ }
+ doc->m_Selection->blockSignals(false);
+
if (trans)
trans.commit();
doc->SnapGrid = savedAlignGrid;
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20445&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Mon Oct 5 12:11:16 2015
@@ -13862,6 +13862,14 @@
}
DoDrawing = false;
view()->updatesOn(false);
+
+ QList<PageItem*> selectedItems = m_Selection->items();
+ qStableSort(selectedItems.begin(), selectedItems.end(), compareItemLevel);
+
+ Selection selection(this, false);
+ for (int i = 0; i < selectedItems.count(); ++i)
+ selection.addItem(selectedItems.at(i));
+
if (mdData.type==0) // Copy and offset or set a gap
{
double dH = mdData.copyShiftGapH / docUnitRatio;
@@ -13873,12 +13881,12 @@
if (mdData.copyShiftOrGap==1)
{
if (dH != 0.0)
- dH2 += m_Selection->width();
+ dH2 += selection.width();
if (dV != 0.0)
- dV2 += m_Selection->height();
+ dV2 += selection.height();
}
ScriXmlDoc ss;
- QString BufferS = ss.WriteElem(this, m_Selection);
+ QString BufferS = ss.WriteElem(this, &selection);
//FIXME: stop using m_View
m_View->Deselect(true);
for (int i=0; i<mdData.copyCount; ++i)
@@ -13929,10 +13937,10 @@
else if (mdData.type==1) // Create a grid of duplicated items
{
int copyCount = mdData.gridRows * mdData.gridCols;
- double dX = mdData.gridGapH/docUnitRatio + m_Selection->width();
- double dY = mdData.gridGapV/docUnitRatio + m_Selection->height();
+ double dX = mdData.gridGapH / docUnitRatio + selection.width();
+ double dY = mdData.gridGapV / docUnitRatio + selection.height();
ScriXmlDoc ss;
- QString BufferS = ss.WriteElem(this, m_Selection);
+ QString BufferS = ss.WriteElem(this, &selection);
for (int i = 0; i < mdData.gridRows; ++i) //skip 0, the item is the one we are copying
{
for (int j = 0; j < mdData.gridCols; ++j) //skip 0, the item is the one we are copying
More information about the scribus-commit
mailing list