r18357 by jghali - #11645: Relative Z-index should keep same when grouping items
scribus-commit
scribus-commit at lists.scribus.net
Tue Jul 9 21:30:49 UTC 2013
Author: jghali
Date: Tue Jul 9 21:30:49 2013
New Revision: 18357
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18357
Log:
#11645: Relative Z-index should keep same when grouping items
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/scribusdoc.cpp
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=18357&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Tue Jul 9 21:30:49 2013
@@ -879,18 +879,19 @@
checkChanges();
}
-int PageItem::level()
-{
+int PageItem::level() const
+{
+ PageItem* thisItem = const_cast<PageItem*>(this);
if (Parent == NULL)
{
if (m_Doc)
{
QList<PageItem*>* items = OnMasterPage.isEmpty() ? &m_Doc->DocItems : &m_Doc->MasterItems;
- return (items->indexOf(this) + 1);
+ return (items->indexOf(thisItem) + 1);
}
return 0;
}
- return (Parent->asGroupFrame()->groupItemList.indexOf(this) + 1);
+ return (Parent->asGroupFrame()->groupItemList.indexOf(thisItem) + 1);
}
void PageItem::moveBy(const double dX, const double dY, bool drawingOnly)
@@ -10476,4 +10477,9 @@
return QString(xml.c_str());
}
-
+bool compareItemLevel(const PageItem* item1, const PageItem* item2)
+{
+ int level1 = item1->level();
+ int level2 = item2->level();
+ return (level1 < level2);
+}
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18357&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Tue Jul 9 21:30:49 2013
@@ -319,7 +319,7 @@
//>> ********* Functions for user interaction with the item **********
- int level(); ///< Get item level relative to its parent doc or group
+ int level() const; ///< Get item level relative to its parent doc or group
void saxx(SaxHandler& handler, const Xml_string& elemtag) const {}
void saxx(SaxHandler& handler) const {}
@@ -1768,4 +1768,6 @@
Q_DECLARE_METATYPE(PageItem*)
+bool compareItemLevel(const PageItem* item1, const PageItem* item2);
+
#endif
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18357&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Jul 9 21:30:49 2013
@@ -14963,7 +14963,9 @@
UndoTransaction *activeTransaction = NULL;
if(UndoManager::undoEnabled())
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IGroup,Um::Group,"",Um::IGroup));
- uint selectedItemCount = itemSelection->count();
+ QList<PageItem*> selectedItems = itemSelection->items();
+ qStableSort(selectedItems.begin(), selectedItems.end(), compareItemLevel);
+ uint selectedItemCount = selectedItems.count();
QString tooltip = Um::ItemsInvolved + "\n";
if (selectedItemCount > Um::ItemsInvolvedLimit)
tooltip = Um::ItemsInvolved2 + "\n";
@@ -14971,7 +14973,7 @@
{
for (uint c=0; c < selectedItemCount; ++c)
{
- currItem = itemSelection->itemAt(c);
+ currItem = selectedItems.at(c);
currItem->setLocked(lock);
//if (m_ScMW && ScCore->usingGUI())
// m_ScMW->scrActions["itemLock"]->setChecked(lock);
@@ -14980,10 +14982,10 @@
}
}
itemSelection->getVisualGroupRect(&x, &y, &w, &h);
- int lowestItem = 999999;
- for (uint a=0; a<selectedItemCount; ++a)
- {
- currItem = itemSelection->itemAt(a);
+ int lowestItem = std::numeric_limits<int>::max();
+ for (uint a=0; a < selectedItemCount; ++a)
+ {
+ currItem = selectedItems.at(a);
currItem->gXpos = currItem->xPos() - x;
currItem->gYpos = currItem->yPos() - y;
currItem->gWidth = w;
@@ -14996,7 +14998,7 @@
double maxy = -std::numeric_limits<double>::max();
for (uint ep = 0; ep < selectedItemCount; ++ep)
{
- PageItem* currItem = itemSelection->itemAt(ep);
+ PageItem* currItem = selectedItems.at(ep);
double x1, x2, y1, y2;
currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
minx = qMin(minx, x1);
@@ -15020,7 +15022,7 @@
undoManager->setUndoEnabled(true);
for (uint c = 0; c < selectedItemCount; ++c)
{
- currItem = itemSelection->itemAt(c);
+ currItem = selectedItems.at(c);
int d = Items->indexOf(currItem);
groupItem->groupItemList.append(Items->takeAt(d));
currItem->Parent = groupItem;
@@ -16837,35 +16839,35 @@
NumStruct * numS = NULL;
for (int i=0; i < docParagraphStyles.count(); ++i)
{
- if (docParagraphStyles[i].hasNum())
- {
- ParagraphStyle &style = docParagraphStyles[i];
- QString name = style.numName();
- if (numerations.contains(name))
- numS = numerations.value(name);
- else
- {
- numS = new NumStruct;
- numS->m_name = name;
- }
- num.numFormat = (NumFormat) style.numFormat();
- num.prefix = style.numPrefix();
- num.suffix = style.numSuffix();
- num.start = style.numStart();
- int level = style.numLevel();
- if (level >= numS->m_counters.count())
- {
- for (int i=numS->m_counters.count(); i <= level; ++i)
- {
- numS->m_nums.insert(i,num);
- numS->m_counters.insert(i, 0);
- }
- }
- numS->m_nums.replace(level, num);
- numS->m_counters.replace(level, num.start -1);
- numS->m_lastlevel = -1;
- numerations.insert(numS->m_name, numS);
- }
+ ParagraphStyle &style = docParagraphStyles[i];
+ if (!style.hasNum())
+ continue;
+
+ QString name = style.numName();
+ if (numerations.contains(name))
+ numS = numerations.value(name);
+ else
+ {
+ numS = new NumStruct;
+ numS->m_name = name;
+ }
+ num.numFormat = (NumFormat) style.numFormat();
+ num.prefix = style.numPrefix();
+ num.suffix = style.numSuffix();
+ num.start = style.numStart();
+ int level = style.numLevel();
+ if (level >= numS->m_counters.count())
+ {
+ for (int i=numS->m_counters.count(); i <= level; ++i)
+ {
+ numS->m_nums.insert(i,num);
+ numS->m_counters.insert(i, 0);
+ }
+ }
+ numS->m_nums.replace(level, num);
+ numS->m_counters.replace(level, num.start -1);
+ numS->m_lastlevel = -1;
+ numerations.insert(numS->m_name, numS);
}
if (!numerations.contains("default"))
Modified: trunk/Scribus/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18357&path=/trunk/Scribus/scribus/selection.cpp
==============================================================================
--- trunk/Scribus/scribus/selection.cpp (original)
+++ trunk/Scribus/scribus/selection.cpp Tue Jul 9 21:30:49 2013
@@ -243,6 +243,19 @@
m_SelList.removeAt(index);
}
return NULL;
+}
+
+QList<PageItem*> Selection::items() const
+{
+ QList<PageItem*> selectedItems;
+ for (int i = 0; i < m_SelList.count(); ++i)
+ {
+ QPointer<PageItem> pi = m_SelList.at(i);
+ if (pi.isNull())
+ continue;
+ selectedItems.append(pi.data());
+ }
+ return selectedItems;
}
bool Selection::removeFirst()
Modified: trunk/Scribus/scribus/selection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18357&path=/trunk/Scribus/scribus/selection.h
==============================================================================
--- trunk/Scribus/scribus/selection.h (original)
+++ trunk/Scribus/scribus/selection.h Tue Jul 9 21:30:49 2013
@@ -138,6 +138,7 @@
const SelectionList& selectionList() const {return m_SelList;}
PageItem *itemAt(int index=0) { return itemAt_(index); }
const PageItem *itemAt(int index=0) const { return const_cast<Selection*>(this)->itemAt_(index); }
+ QList<PageItem*> items() const;
QStringList getSelectedItemsByName() const;
bool isMultipleSelection() const { return (m_SelList.count() > 1); }
bool isGUISelection() const { return m_isGUISelection; }
More information about the scribus-commit
mailing list