r23249 by jghali - #15836: Undoing on Attach Text to Path returns a bigger selected Text Frame
scribus-commit
scribus-commit at lists.scribus.net
Thu Oct 10 06:12:31 UTC 2019
Author: jghali
Date: Thu Oct 10 06:12:31 2019
New Revision: 23249
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23249
Log:
#15836: Undoing on Attach Text to Path returns a bigger selected Text Frame
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/scpage.cpp
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusdoc.h
trunk/Scribus/scribus/selection.cpp
trunk/Scribus/scribus/selection.h
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23249&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Thu Oct 10 06:12:31 2019
@@ -6849,8 +6849,9 @@
QString fill(state->get("OLD_FILL"));
if (!isUndo)
fill = state->get("NEW_FILL");
- select();
- m_Doc->itemSelection_SetItemBrush(fill);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetItemBrush(fill, &tempSelection);
}
void PageItem::restoreResTyp(SimpleState *state, bool isUndo)
@@ -6867,8 +6868,9 @@
int shade = state->getInt("OLD_SHADE");
if (!isUndo)
shade = state->getInt("NEW_SHADE");
- select();
- m_Doc->itemSelection_SetItemBrushShade(shade);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetItemBrushShade(shade, &tempSelection);
}
void PageItem::restoreLineColor(SimpleState *state, bool isUndo)
@@ -6876,8 +6878,9 @@
QString fill(state->get("OLD_COLOR"));
if (!isUndo)
fill = state->get("NEW_COLOR");
- select();
- m_Doc->itemSelection_SetItemPen(fill);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetItemPen(fill, &tempSelection);
}
void PageItem::restoreLineShade(SimpleState *state, bool isUndo)
@@ -6885,8 +6888,9 @@
int shade = state->getInt("OLD_SHADE");
if (!isUndo)
shade = state->getInt("NEW_SHADE");
- select();
- m_Doc->itemSelection_SetItemPenShade(shade);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetItemPenShade(shade, &tempSelection);
}
void PageItem::restoreFillTP(SimpleState *state, bool isUndo)
@@ -6894,8 +6898,9 @@
double tp = state->getDouble("OLD_TP");
if (!isUndo)
tp = state->getDouble("NEW_TP");
- select();
- m_Doc->itemSelection_SetItemFillTransparency(tp);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetItemFillTransparency(tp, &tempSelection);
}
void PageItem::restoreLineTP(SimpleState *state, bool isUndo)
@@ -6903,8 +6908,9 @@
double tp = state->getDouble("OLD_TP");
if (!isUndo)
tp = state->getDouble("NEW_TP");
- select();
- m_Doc->itemSelection_SetItemLineTransparency(tp);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetItemLineTransparency(tp, &tempSelection);
}
@@ -6913,8 +6919,9 @@
Qt::PenStyle ps = static_cast<Qt::PenStyle>(state->getInt("OLD_STYLE"));
if (!isUndo)
ps = static_cast<Qt::PenStyle>(state->getInt("NEW_STYLE"));
- select();
- m_Doc->itemSelection_SetLineArt(ps);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetLineArt(ps, &tempSelection);
}
void PageItem::restoreLineEnd(SimpleState *state, bool isUndo)
@@ -6922,8 +6929,9 @@
Qt::PenCapStyle pcs = static_cast<Qt::PenCapStyle>(state->getInt("OLD_STYLE"));
if (!isUndo)
pcs = static_cast<Qt::PenCapStyle>(state->getInt("NEW_STYLE"));
- select();
- m_Doc->itemSelection_SetLineEnd(pcs);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetLineEnd(pcs, &tempSelection);
}
void PageItem::restoreLineJoin(SimpleState *state, bool isUndo)
@@ -6931,8 +6939,9 @@
Qt::PenJoinStyle pjs = static_cast<Qt::PenJoinStyle>(state->getInt("OLD_STYLE"));
if (!isUndo)
pjs = static_cast<Qt::PenJoinStyle>(state->getInt("NEW_STYLE"));
- select();
- m_Doc->itemSelection_SetLineJoin(pjs);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetLineJoin(pjs, &tempSelection);
}
void PageItem::restoreLineWidth(SimpleState *state, bool isUndo)
@@ -6940,8 +6949,9 @@
double w = state->getDouble("OLD_LINEWIDTH");
if (!isUndo)
w = state->getDouble("NEW_LINEWIDTH");
- select();
- m_Doc->itemSelection_SetLineWidth(w);
+ Selection tempSelection(0, false);
+ tempSelection.addItem(this);
+ m_Doc->itemSelection_SetLineWidth(w, &tempSelection);
}
void PageItem::restoreCustomLineStyle(SimpleState *state, bool isUndo)
Modified: trunk/Scribus/scribus/scpage.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23249&path=/trunk/Scribus/scribus/scpage.cpp
==============================================================================
--- trunk/Scribus/scribus/scpage.cpp (original)
+++ trunk/Scribus/scribus/scpage.cpp Thu Oct 10 06:12:31 2019
@@ -384,11 +384,11 @@
if (isUndo)
{
//CB #3373 reinsert at old position and renumber items
- PageItem* ite = itemList.at(id2);
- if (ite->Parent && ite->Parent->isGroup())
- ite->Parent->asGroupFrame()->groupItemList.insert(id, ite);
- else
- m_Doc->Items->insert(id, ite);
+ PageItem* oldItem = itemList.at(id2);
+ if (oldItem->Parent && oldItem->Parent->isGroup())
+ oldItem->Parent->asGroupFrame()->groupItemList.insert(id, oldItem);
+ else
+ m_Doc->Items->insert(id, oldItem);
for (int i = 0; i < itemList.count(); ++i)
{
PageItem* ite = itemList.at(i);
@@ -428,10 +428,12 @@
m_Doc->Items->replace(m_Doc->Items->indexOf(newItem), oldItem);
oldItem->updatePolyClip();
m_Doc->adjustItemSize(oldItem);
+ m_Doc->m_Selection->replaceItem(newItem, oldItem);
}
else
{
m_Doc->Items->replace(m_Doc->Items->indexOf(oldItem), newItem);
+ m_Doc->m_Selection->replaceItem(oldItem, newItem);
}
m_Doc->setMasterPageMode(oldMPMode);
}
@@ -454,10 +456,12 @@
m_Doc->adjustItemSize(oldItem);
if (m_Doc->docPatterns.contains(patternName))
m_Doc->removePattern(patternName);
+ m_Doc->m_Selection->replaceItem(newItem, oldItem);
}
else
{
m_Doc->Items->replace(m_Doc->Items->indexOf(oldItem), newItem);
+ m_Doc->m_Selection->replaceItem(oldItem, newItem);
}
m_Doc->setMasterPageMode(oldMPMode);
}
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23249&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Thu Oct 10 06:12:31 2019
@@ -7694,11 +7694,13 @@
}
-void ScribusDoc::itemSelection_SetLineWidth(double w)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetLineWidth(double w, Selection* customSelection)
+{
+ Selection *itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
if (UndoManager::undoEnabled() && selectedItemCount > 1)
@@ -7706,7 +7708,7 @@
Um::IGroup, Um::LineWidth, "", Um::ILineStyle);
for (int i = 0; i < selectedItemCount; ++i)
{
- PageItem *currItem = m_Selection->itemAt(i);
+ PageItem *currItem = itemSelection->itemAt(i);
QRectF oldRect = currItem->getVisualBoundingRect();
//cb moved to setlinewidth
//currItem->m_oldLineWidth = currItem->lineWidth();
@@ -7733,9 +7735,10 @@
-void ScribusDoc::itemSelection_SetLineArt(Qt::PenStyle w)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetLineArt(Qt::PenStyle w, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
UndoTransaction activeTransaction;
@@ -7744,8 +7747,9 @@
activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::LineStyle, "", Um::ILineStyle);
for (int i = 0; i < selectedItemCount; ++i)
{
- m_Selection->itemAt(i)->setLineStyle(w);
- m_Selection->itemAt(i)->update();
+ PageItem* item = itemSelection->itemAt(i);
+ item->setLineStyle(w);
+ item->update();
}
if (activeTransaction)
activeTransaction.commit();
@@ -7755,19 +7759,22 @@
-void ScribusDoc::itemSelection_SetLineJoin(Qt::PenJoinStyle w)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetLineJoin(Qt::PenJoinStyle w, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
if (UndoManager::undoEnabled() && selectedItemCount > 1)
activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::LineJoin, "", Um::ILineStyle);
for (int i = 0; i < selectedItemCount; ++i)
{
- m_Selection->itemAt(i)->setLineJoin(w);
- m_Selection->itemAt(i)->update();
+ PageItem* item = itemSelection->itemAt(i);
+ item->setLineJoin(w);
+ item->update();
}
if (activeTransaction)
activeTransaction.commit();
@@ -7777,19 +7784,22 @@
-void ScribusDoc::itemSelection_SetLineEnd(Qt::PenCapStyle w)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetLineEnd(Qt::PenCapStyle w, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
if (UndoManager::undoEnabled() && selectedItemCount > 1)
activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::LineEnd, "", Um::ILineStyle);
for (int i = 0; i < selectedItemCount; ++i)
{
- m_Selection->itemAt(i)->setLineEnd(w);
- m_Selection->itemAt(i)->update();
+ PageItem* item = itemSelection->itemAt(i);
+ item->setLineEnd(w);
+ item->update();
}
if (activeTransaction)
activeTransaction.commit();
@@ -7818,7 +7828,7 @@
{
if (!AddFont(font))
{
- PageItem *currItem = m_Selection->itemAt(0);
+ PageItem *currItem = itemSelection->itemAt(0);
newFont = currItem->currentCharStyle().font().scName();
}
}
@@ -7904,27 +7914,28 @@
}
-void ScribusDoc::itemSelection_SetItemPen(QString farbe)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemPen(QString color, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount <= 0)
return;
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
- if (farbe == CommonStrings::tr_NoneColor)
- farbe = CommonStrings::None;
+ if (color == CommonStrings::tr_NoneColor)
+ color = CommonStrings::None;
if (selectedItemCount > 1 && UndoManager::undoEnabled())
activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup,
- Um::IGroup, Um::SetLineColor, farbe, Um::IFill);
+ Um::IGroup, Um::SetLineColor, color, Um::IFill);
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
- if ((currItem->asLine()) && (farbe == CommonStrings::None))
+ currItem = itemSelection->itemAt(i);
+ if ((currItem->asLine()) && (color == CommonStrings::None))
continue;
- currItem->setLineColor(farbe);
+ currItem->setLineColor(color);
currItem->update();
}
if (activeTransaction)
@@ -8049,37 +8060,41 @@
itemSelection_ApplyCharStyle(newStyle, customSelection, "OUTLINE_WIDTH");
}
-void ScribusDoc::itemSelection_SetItemBrush(QString farbe)
-{
- if (farbe == CommonStrings::tr_NoneColor)
- farbe = CommonStrings::None;
- int selectedItemCount = m_Selection->count();
- if (selectedItemCount != 0)
- {
- UndoTransaction activeTransaction;
- m_updateManager.setUpdatesDisabled();
- if (selectedItemCount > 1 && UndoManager::undoEnabled())
- activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup,
- Um::IGroup, Um::SetFill, farbe, Um::IFill);
- PageItem *currItem;
- for (int i = 0; i < selectedItemCount; ++i)
- {
- currItem = m_Selection->itemAt(i);
- currItem->setFillColor(farbe);
- currItem->update();
- }
- if (activeTransaction)
- activeTransaction.commit();
- m_updateManager.setUpdatesEnabled();
- changed();
- }
-}
-
-void ScribusDoc::itemSelection_SetItemBrushShade(int sha)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemBrush(QString colorName, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
+ if (colorName == CommonStrings::tr_NoneColor)
+ colorName = CommonStrings::None;
+
+ UndoTransaction activeTransaction;
+ m_updateManager.setUpdatesDisabled();
+ if (selectedItemCount > 1 && UndoManager::undoEnabled())
+ activeTransaction = m_undoManager->beginTransaction(Um::SelectionGroup,
+ Um::IGroup, Um::SetFill, colorName, Um::IFill);
+ PageItem *currItem;
+ for (int i = 0; i < selectedItemCount; ++i)
+ {
+ currItem = itemSelection->itemAt(i);
+ currItem->setFillColor(colorName);
+ currItem->update();
+ }
+ if (activeTransaction)
+ activeTransaction.commit();
+ m_updateManager.setUpdatesEnabled();
+ changed();
+}
+
+void ScribusDoc::itemSelection_SetItemBrushShade(int sha, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
+ if (selectedItemCount == 0)
+ return;
+
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
if (UndoManager::undoEnabled() && selectedItemCount > 1)
@@ -8089,7 +8104,7 @@
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
+ currItem = itemSelection->itemAt(i);
currItem->setFillShade(sha);
currItem->update();
}
@@ -8099,11 +8114,13 @@
changed();
}
-void ScribusDoc::itemSelection_SetItemPenShade(int sha)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemPenShade(int sha, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
if (selectedItemCount > 1 && UndoManager::undoEnabled())
@@ -8112,7 +8129,7 @@
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
+ currItem = itemSelection->itemAt(i);
currItem->setLineShade(sha);
currItem->update();
}
@@ -8122,11 +8139,13 @@
changed();
}
-void ScribusDoc::itemSelection_SetItemGradMask(int typ)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemGradMask(int typ, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
@@ -8134,7 +8153,7 @@
activeTransaction = m_undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradTypeMask,"",Um::IFill);
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
+ currItem = itemSelection->itemAt(i);
currItem->setMaskType(typ);
if ((typ > 0) && (typ < 9))
currItem->updateGradientVectors();
@@ -8146,19 +8165,21 @@
changed();
}
-void ScribusDoc::itemSelection_SetItemGradStroke(int typ)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemGradStroke(int typ, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
UndoTransaction activeTransaction;
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
if (UndoManager::undoEnabled())
- activeTransaction = m_undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradTypeMask,"",Um::IFill);
+ activeTransaction = m_undoManager->beginTransaction(Um::Selection, Um::IFill, Um::GradTypeMask, "", Um::IFill);
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
+ currItem = itemSelection->itemAt(i);
currItem->setStrokeGradientType(typ);
if (currItem->strokeGradientType() == 0)
{
@@ -8196,11 +8217,13 @@
changed();
}
-void ScribusDoc::itemSelection_SetItemGradFill(int typ)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemGradFill(int typ, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
UndoTransaction trans;
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
@@ -8208,7 +8231,7 @@
trans = m_undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::SetFill,"",Um::IFill);
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
+ currItem = itemSelection->itemAt(i);
currItem->setGradientType(typ);
switch (currItem->gradientType())
{
@@ -8279,7 +8302,26 @@
changed();
}
-void ScribusDoc::itemSelection_SetItemPatternFill(const QString& pattern)
+void ScribusDoc::itemSelection_SetItemPatternFill(const QString& pattern, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
+ if (selectedItemCount == 0)
+ return;
+
+ m_updateManager.setUpdatesDisabled();
+ PageItem *currItem;
+ for (int i = 0; i < selectedItemCount; ++i)
+ {
+ currItem = itemSelection->itemAt(i);
+ currItem->setPattern(pattern);
+ currItem->update();
+ }
+ m_updateManager.setUpdatesEnabled();
+ changed();
+}
+
+void ScribusDoc::itemSelection_SetItemPatternProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)
{
int selectedItemCount = m_Selection->count();
if (selectedItemCount == 0)
@@ -8289,110 +8331,103 @@
for (int i = 0; i < selectedItemCount; ++i)
{
currItem = m_Selection->itemAt(i);
- currItem->setPattern(pattern);
+ currItem->setPatternTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY);
+ currItem->setPatternFlip(mirrorX, mirrorY);
currItem->update();
}
m_updateManager.setUpdatesEnabled();
changed();
}
-void ScribusDoc::itemSelection_SetItemPatternProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemStrokePattern(const QString& pattern, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
- currItem->setPatternTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY);
- currItem->setPatternFlip(mirrorX, mirrorY);
+ currItem = itemSelection->itemAt(i);
+ currItem->setStrokePattern(pattern);
currItem->update();
}
m_updateManager.setUpdatesEnabled();
changed();
}
-void ScribusDoc::itemSelection_SetItemStrokePattern(const QString& pattern)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemStrokePatternProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, double space, bool mirrorX, bool mirrorY, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
- currItem->setStrokePattern(pattern);
+ currItem = itemSelection->itemAt(i);
+ currItem->setStrokePatternTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY, space);
+ currItem->setStrokePatternFlip(mirrorX, mirrorY);
currItem->update();
}
m_updateManager.setUpdatesEnabled();
changed();
}
-void ScribusDoc::itemSelection_SetItemStrokePatternProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, double space, bool mirrorX, bool mirrorY)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemStrokePatternType(bool type, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
- currItem->setStrokePatternTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY, space);
- currItem->setStrokePatternFlip(mirrorX, mirrorY);
+ currItem = itemSelection->itemAt(i);
+ currItem->setStrokePatternToPath(type);
currItem->update();
}
m_updateManager.setUpdatesEnabled();
changed();
}
-void ScribusDoc::itemSelection_SetItemStrokePatternType(bool type)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemPatternMask(const QString& pattern, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
- currItem->setStrokePatternToPath(type);
+ currItem = itemSelection->itemAt(i);
+ currItem->setPatternMask(pattern);
currItem->update();
}
m_updateManager.setUpdatesEnabled();
changed();
}
-void ScribusDoc::itemSelection_SetItemPatternMask(const QString& pattern)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemPatternMaskProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
m_updateManager.setUpdatesDisabled();
PageItem *currItem;
for (int i = 0; i < selectedItemCount; ++i)
{
- currItem = m_Selection->itemAt(i);
- currItem->setPatternMask(pattern);
- currItem->update();
- }
- m_updateManager.setUpdatesEnabled();
- changed();
-}
-
-void ScribusDoc::itemSelection_SetItemPatternMaskProps(double imageScaleX, double imageScaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY)
-{
- int selectedItemCount = m_Selection->count();
- if (selectedItemCount == 0)
- return;
- m_updateManager.setUpdatesDisabled();
- PageItem *currItem;
- for (int i = 0; i < selectedItemCount; ++i)
- {
- currItem = m_Selection->itemAt(i);
+ currItem = itemSelection->itemAt(i);
currItem->setMaskTransform(imageScaleX, imageScaleY, offsetX, offsetY, rotation, skewX, skewY);
currItem->setMaskFlip(mirrorX, mirrorY);
currItem->update();
@@ -11470,14 +11505,16 @@
}
-void ScribusDoc::itemSelection_SetItemFillTransparency(double t)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemFillTransparency(double t, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
for (int i = 0; i < selectedItemCount; ++i)
{
- PageItem *currItem = m_Selection->itemAt(i);
+ PageItem *currItem = itemSelection->itemAt(i);
if (currItem->isGroup())
continue;
currItem->setFillTransparency(t);
@@ -11487,14 +11524,16 @@
}
-void ScribusDoc::itemSelection_SetItemLineTransparency(double t)
-{
- int selectedItemCount = m_Selection->count();
+void ScribusDoc::itemSelection_SetItemLineTransparency(double t, Selection* customSelection)
+{
+ Selection* itemSelection = (customSelection!=nullptr) ? customSelection : m_Selection;
+ int selectedItemCount = itemSelection->count();
if (selectedItemCount == 0)
return;
+
for (int i = 0; i < selectedItemCount; ++i)
{
- PageItem *currItem = m_Selection->itemAt(i);
+ PageItem *currItem = itemSelection->itemAt(i);
currItem->setLineTransparency(t);
}
regionsChanged()->update(QRectF());
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23249&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Thu Oct 10 06:12:31 2019
@@ -1073,10 +1073,10 @@
void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection = nullptr);
void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection = nullptr);
void itemSelection_SetSoftShadow(bool has, QString color, double dx, double dy, double radius, int shade, double opac, int blend, bool erase, bool objopa);
- void itemSelection_SetLineWidth(double w);
- void itemSelection_SetLineArt(Qt::PenStyle w);
- void itemSelection_SetLineJoin(Qt::PenJoinStyle w);
- void itemSelection_SetLineEnd(Qt::PenCapStyle w);
+ void itemSelection_SetLineWidth(double w, Selection* customSelection = nullptr);
+ void itemSelection_SetLineArt(Qt::PenStyle w, Selection* customSelection = nullptr);
+ void itemSelection_SetLineJoin(Qt::PenJoinStyle w, Selection* customSelection = nullptr);
+ void itemSelection_SetLineEnd(Qt::PenCapStyle w, Selection* customSelection = nullptr);
void itemSelection_SetAlignment(int w, Selection* customSelection = nullptr);
void itemSelection_SetDirection(int w, Selection* customSelection = nullptr);
void itemSelection_SetLineSpacing(double w, Selection* customSelection = nullptr);
@@ -1484,11 +1484,11 @@
void itemSelection_TruncateItem(Selection* customSelection = nullptr);
//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
void itemSelection_DeleteItem(Selection* customSelection = nullptr, bool forceDeletion=false);
- void itemSelection_SetItemFillTransparency(double t);
+ void itemSelection_SetItemFillTransparency(double t, Selection* customSelection = nullptr);
void itemSelection_SetHyphenWordMin(int wordMin, Selection* customSelection = nullptr);
void itemSelection_SetHyphenConsecutiveLines(int consecutiveLines, Selection* customSelection = nullptr);
void itemSelection_SetHyphenChar(uint hyphenChar, Selection* customSelection = nullptr);
- void itemSelection_SetItemLineTransparency(double t);
+ void itemSelection_SetItemLineTransparency(double t, Selection* customSelection = nullptr);
void itemSelection_SetItemFillBlend(int t);
void itemSelection_SetItemLineBlend(int t);
void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection = nullptr);
@@ -1554,20 +1554,20 @@
void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection = nullptr);
void itemSelection_ApplyArrowScale(int startArrowSc, int endArrowSc, Selection* customSelection);
- void itemSelection_SetItemPen(QString farbe);
- void itemSelection_SetItemPenShade(int sha);
- void itemSelection_SetItemGradStroke(int typ);
- void itemSelection_SetItemBrush(QString farbe);
- void itemSelection_SetItemBrushShade(int sha);
- void itemSelection_SetItemGradMask(int typ);
- void itemSelection_SetItemGradFill(int typ);
- void itemSelection_SetItemPatternFill(const QString& pattern);
+ void itemSelection_SetItemPen(QString color, Selection* customSelection = nullptr);
+ void itemSelection_SetItemPenShade(int sha, Selection* customSelection = nullptr);
+ void itemSelection_SetItemGradStroke(int typ, Selection* customSelection = nullptr);
+ void itemSelection_SetItemBrush(QString colorName, Selection* customSelection = nullptr);
+ void itemSelection_SetItemBrushShade(int sha, Selection* customSelection = nullptr);
+ void itemSelection_SetItemGradMask(int typ, Selection* customSelection = nullptr);
+ void itemSelection_SetItemGradFill(int typp, Selection* customSelection = nullptr);
+ void itemSelection_SetItemPatternFill(const QString& pattern, Selection* customSelection = nullptr);
void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
- void itemSelection_SetItemStrokePattern(const QString& pattern);
- void itemSelection_SetItemStrokePatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, double space, bool mirrorX, bool mirrorY);
- void itemSelection_SetItemStrokePatternType(bool type);
- void itemSelection_SetItemPatternMask(const QString& pattern);
- void itemSelection_SetItemPatternMaskProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY);
+ void itemSelection_SetItemStrokePattern(const QString& pattern, Selection* customSelection = nullptr);
+ void itemSelection_SetItemStrokePatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, double space, bool mirrorX, bool mirrorY, Selection* customSelection = nullptr);
+ void itemSelection_SetItemStrokePatternType(bool type, Selection* customSelection = nullptr);
+ void itemSelection_SetItemPatternMask(const QString& pattern, Selection* customSelection = nullptr);
+ void itemSelection_SetItemPatternMaskProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY, Selection* customSelection = nullptr);
// Table related slots.
Modified: trunk/Scribus/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23249&path=/trunk/Scribus/scribus/selection.cpp
==============================================================================
--- trunk/Scribus/scribus/selection.cpp (original)
+++ trunk/Scribus/scribus/selection.cpp Thu Oct 10 06:12:31 2019
@@ -154,7 +154,7 @@
return ret;
if (m_SelList.count() == 1)
{
- QPointer<PageItem> pi=m_SelList.first();
+ QPointer<PageItem> pi = m_SelList.first();
//Quick check to see if the pointer is nullptr, if its nullptr, we should remove it from the list now
if (pi.isNull())
{
@@ -235,7 +235,7 @@
{
if (!m_SelList.isEmpty() && index<m_SelList.count())
{
- QPointer<PageItem> pi=m_SelList[index];
+ QPointer<PageItem> pi = m_SelList[index];
//If not nullptr return it, otherwise remove from the list and return nullptr
if (!pi.isNull())
return pi;
@@ -330,6 +330,17 @@
bool itemsRemoved = (oldSelCount != m_SelList.count());
return itemsRemoved;
+}
+
+void Selection::replaceItem(PageItem* oldItem, PageItem* newItem)
+{
+ delaySignalsOn();
+
+ int itemIndex = findItem(oldItem);
+ if (itemIndex >= 0)
+ m_SelList.replace(itemIndex, newItem);
+
+ delaySignalsOff();
}
PageItem* Selection::takeItem(int itemIndex)
Modified: trunk/Scribus/scribus/selection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23249&path=/trunk/Scribus/scribus/selection.h
==============================================================================
--- trunk/Scribus/scribus/selection.h (original)
+++ trunk/Scribus/scribus/selection.h Thu Oct 10 06:12:31 2019
@@ -98,7 +98,7 @@
*/
bool removeItem(PageItem *item);
/**
- * \briefRemove items from specified layer
+ * \brief Remove items from specified layer
*/
bool removeItemsOfLayer(int layedID);
/**
@@ -110,6 +110,12 @@
* \brief Unused
*/
bool removeGroup();
+
+ /**
+ * Replace item in selection by another
+ */
+ void replaceItem(PageItem* oldItem, PageItem* newItem);
+
/**
* \brief Remove an item from list listNumber and return a pointer to it
* @param itemIndex Index of the item in the list
More information about the scribus-commit
mailing list