r23269 by jghali - Refactor Selection's connectItemToGUI() and preprendItem()
scribus-commit
scribus-commit at lists.scribus.net
Sun Oct 20 10:28:30 UTC 2019
Author: jghali
Date: Sun Oct 20 10:28:30 2019
New Revision: 23269
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23269
Log:
Refactor Selection's connectItemToGUI() and preprendItem()
Modified:
trunk/Scribus/scribus/selection.cpp
trunk/Scribus/scribus/selection.h
Modified: trunk/Scribus/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23269&path=/trunk/Scribus/scribus/selection.cpp
==============================================================================
--- trunk/Scribus/scribus/selection.cpp (original)
+++ trunk/Scribus/scribus/selection.cpp Sun Oct 20 10:28:30 2019
@@ -109,7 +109,7 @@
(*it)->setSelected(false);
}
m_SelList = other.m_SelList;
- if (m_isGUISelection && !m_SelList.isEmpty())
+ if (m_isGUISelection)
m_sigSelectionChanged = true;
if (emptyOther)
other.clear();
@@ -145,28 +145,26 @@
bool Selection::connectItemToGUI()
{
- bool ret = false;
if (!m_isGUISelection || m_SelList.isEmpty())
- return ret;
- if (m_SelList.count() == 1)
- {
- 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())
- {
- m_SelList.removeAll(pi);
- return ret;
- }
- ret = pi->connectToGUI();
- pi->emitAllToGUI();
- m_sigSelectionChanged = true;
- }
- else
- {
- ret = m_SelList.first()->connectToGUI();
- m_SelList.first()->emitAllToGUI();
- m_sigSelectionChanged = true;
- }
+ return false;
+
+ 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
+ while (pi.isNull())
+ {
+ m_SelList.removeAll(pi);
+ if (m_SelList.isEmpty())
+ break;
+ pi = m_SelList.first();
+ }
+
+ if (pi.isNull())
+ return false;
+
+ bool ret = pi->connectToGUI();
+ pi->emitAllToGUI();
+ m_sigSelectionChanged = true;
+
sendSignals(false);
return ret;
}
@@ -230,24 +228,23 @@
return true;
}
-bool Selection::prependItem(PageItem *item, bool /*doEmit*/)
+bool Selection::prependItem(PageItem *item)
{
if (item == nullptr)
return false;
- if (!m_SelList.contains(item))
- {
- if (m_isGUISelection && !m_SelList.isEmpty())
- m_SelList[0]->disconnectFromGUI();
- m_SelList.prepend(item);
- if (m_isGUISelection /*&& doEmit*/)
- {
- item->setSelected(true);
- m_sigSelectionChanged = true;
- }
- sendSignals();
- return true;
- }
- return false;
+ if (m_SelList.contains(item))
+ return false;
+
+ if (m_isGUISelection && !m_SelList.isEmpty())
+ m_SelList[0]->disconnectFromGUI();
+ m_SelList.prepend(item);
+ if (m_isGUISelection)
+ {
+ item->setSelected(true);
+ m_sigSelectionChanged = true;
+ }
+ sendSignals();
+ return true;
}
PageItem *Selection::itemAt_(int index)
Modified: trunk/Scribus/scribus/selection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23269&path=/trunk/Scribus/scribus/selection.h
==============================================================================
--- trunk/Scribus/scribus/selection.h (original)
+++ trunk/Scribus/scribus/selection.h Sun Oct 20 10:28:30 2019
@@ -92,7 +92,7 @@
* @param doEmit call emitAllToGUI()
* @return If the item was added
*/
- bool prependItem(PageItem *item, bool doEmit=true);
+ bool prependItem(PageItem *item);
bool containsItem(PageItem *item) const { return m_SelList.contains(item); }
More information about the scribus-commit
mailing list