r23175 by jghali - #15798 follow-up: when marking a layer as locked or invisible, remove from selection items of corresponding layers
scribus-commit
scribus-commit at lists.scribus.net
Tue Sep 3 01:05:50 UTC 2019
Author: jghali
Date: Tue Sep 3 01:05:50 2019
New Revision: 23175
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23175
Log:
#15798 follow-up: when marking a layer as locked or invisible, remove from selection items of corresponding layers
Modified:
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/selection.cpp
trunk/Scribus/scribus/selection.h
trunk/Scribus/scribus/ui/layers.cpp
trunk/Scribus/scribus/ui/layers.h
trunk/Scribus/scribus/ui/outlinepalette.cpp
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23175&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Sep 3 01:05:50 2019
@@ -4346,13 +4346,13 @@
m_styleManager->setDoc(nullptr);
marksManager->setDoc(nullptr);
nsEditor->setDoc(nullptr);
- layerPalette->ClearInhalt();
+ layerPalette->clearContent();
docCheckerPalette->buildErrorList(nullptr);
HaveDoc--;
delete doc;
doc = nullptr;
ActWin = nullptr;
- if ( HaveDoc == 0 )
+ if (HaveDoc == 0)
{
QString prefsDocDir( PrefsManager::instance().documentDir() );
if ( QDir().exists(prefsDocDir) )
Modified: trunk/Scribus/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23175&path=/trunk/Scribus/scribus/selection.cpp
==============================================================================
--- trunk/Scribus/scribus/selection.cpp (original)
+++ trunk/Scribus/scribus/selection.cpp Tue Sep 3 01:05:50 2019
@@ -276,49 +276,81 @@
bool Selection::removeItem(PageItem *item)
{
- bool removeOk(false);
- if (!m_SelList.isEmpty() && m_SelList.contains(item))
- {
- removeOk = (m_SelList.removeAll(item)==1);
- if (removeOk)
- {
- if (m_isGUISelection)
- {
- item->setSelected(false);
+ if (m_SelList.isEmpty() || !m_SelList.contains(item))
+ return false;
+
+ bool removeOk = (m_SelList.removeAll(item) == 1);
+ if (removeOk)
+ {
+ if (m_isGUISelection)
+ {
+ item->setSelected(false);
+ item->disconnectFromGUI();
+ }
+ item->isSingleSel = false;
+ }
+
+ if (m_isGUISelection)
+ {
+ m_sigSelectionChanged = true;
+ sendSignals();
+ }
+ return removeOk;
+}
+
+bool Selection::removeItemsOfLayer(int layedID)
+{
+ if (m_SelList.isEmpty())
+ return false;
+
+ int oldSelCount = m_SelList.count();
+
+ delaySignalsOn();
+
+ int selIndex = 0;
+ while (selIndex < m_SelList.count())
+ {
+ QPointer<PageItem> pi = m_SelList.at(selIndex);
+ if (pi.isNull())
+ {
+ removeItem(itemAt(selIndex));
+ continue;
+ }
+
+ if (pi->m_layerID != layedID)
+ {
+ ++selIndex;
+ continue;
+ }
+
+ removeItem(itemAt(selIndex));
+ }
+
+ delaySignalsOff();
+
+ bool itemsRemoved = (oldSelCount != m_SelList.count());
+ return itemsRemoved;
+}
+
+PageItem* Selection::takeItem(int itemIndex)
+{
+ if (m_SelList.isEmpty() || itemIndex >= m_SelList.count())
+ return nullptr;
+
+ PageItem *item = m_SelList[itemIndex];
+ bool removeOk = (m_SelList.removeAll(item) == 1);
+ if (removeOk)
+ {
+ item->isSingleSel = false;
+ if (m_isGUISelection)
+ {
+ item->setSelected(false);
+ m_sigSelectionChanged = true;
+ if (itemIndex == 0)
item->disconnectFromGUI();
- }
- item->isSingleSel = false;
- }
-
- if (m_isGUISelection)
- {
- m_sigSelectionChanged = true;
- sendSignals();
- }
- return removeOk;
- }
- return removeOk;
-}
-
-PageItem* Selection::takeItem(int itemIndex)
-{
- if (!m_SelList.isEmpty() && itemIndex<m_SelList.count())
- {
- PageItem *item = m_SelList[itemIndex];
- bool removeOk = (m_SelList.removeAll(item) == 1);
- if (removeOk)
- {
- item->isSingleSel = false;
- if (m_isGUISelection)
- {
- item->setSelected(false);
- m_sigSelectionChanged = true;
- if (itemIndex == 0)
- item->disconnectFromGUI();
- }
- sendSignals();
- return item;
- }
+ }
+ sendSignals();
+ return item;
}
return nullptr;
}
Modified: trunk/Scribus/scribus/selection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23175&path=/trunk/Scribus/scribus/selection.h
==============================================================================
--- trunk/Scribus/scribus/selection.h (original)
+++ trunk/Scribus/scribus/selection.h Tue Sep 3 01:05:50 2019
@@ -97,6 +97,10 @@
* @param item page item
*/
bool removeItem(PageItem *item);
+ /**
+ * \briefRemove items from specified layer
+ */
+ bool removeItemsOfLayer(int layedID);
/**
* \brief Remove the first item from the list
* @return If the remove was successful
Modified: trunk/Scribus/scribus/ui/layers.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23175&path=/trunk/Scribus/scribus/ui/layers.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/layers.cpp (original)
+++ trunk/Scribus/scribus/ui/layers.cpp Tue Sep 3 01:05:50 2019
@@ -35,6 +35,7 @@
#include "sccombobox.h"
#include "scribus.h"
#include "scribusdoc.h"
+#include "selection.h"
#include "ui/scrspinbox.h"
#include "undomanager.h"
@@ -145,7 +146,7 @@
LayerPaletteLayout->addLayout( Layout1 );
containerWidget->setLayout( LayerPaletteLayout );
setWidget( containerWidget );
- ClearInhalt();
+ clearContent();
languageChange();
connect(newLayerButton, SIGNAL(clicked()), this, SLOT(addLayer()));
@@ -159,7 +160,7 @@
connect(header, SIGNAL(sectionClicked(int)), this, SLOT(toggleAllfromHeader(int)));
}
-void LayerPalette::ClearInhalt()
+void LayerPalette::clearContent()
{
disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
@@ -191,7 +192,7 @@
lowerLayerButton->setEnabled(false);
markActiveLayer(0);
}
- layers=&m_Doc->Layers;
+ layers = &m_Doc->Layers;
rebuildList();
markActiveLayer(m_Doc->activeLayer());
@@ -338,11 +339,11 @@
{
if (!m_Doc)
return;
- int layerCount=m_Doc->layerCount();
+ int layerCount = m_Doc->layerCount();
if (layerCount < 2)
return;
int level = layerCount-1-Table->currentRow();
- int layerID=m_Doc->layerIDFromLevel(level);
+ int layerID = m_Doc->layerIDFromLevel(level);
bool delToo = false;
if (m_Doc->layerContainsItems(layerID))
{
@@ -368,7 +369,7 @@
{
if (!m_Doc)
return;
- int layerCount=m_Doc->layerCount();
+ int layerCount = m_Doc->layerCount();
if ((layerCount < 2) || (Table->currentRow() == 0))
return;
int layerLevel = layerCount-1-Table->currentRow();
@@ -384,7 +385,7 @@
{
if (!m_Doc)
return;
- int layerCount=m_Doc->layerCount();
+ int layerCount = m_Doc->layerCount();
if ((layerCount < 2) || (Table->currentRow() == static_cast<int>(layerCount) - 1))
return;
int layerLevel = layerCount-1-Table->currentRow();
@@ -403,8 +404,8 @@
if (col == 7)
{
int layerLevel = m_Doc->layerCount()-1-row;
- int layerID=m_Doc->layerIDFromLevel(layerLevel);
- if (layerID!=-1)
+ int layerID = m_Doc->layerIDFromLevel(layerLevel);
+ if (layerID != -1)
m_Doc->changeLayerName(layerID, Table->item(row, col)->text());
}
m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
@@ -415,13 +416,16 @@
if (!m_Doc)
return;
int level = QString(sender()->objectName()).toInt();
- int layerID=m_Doc->layerIDFromLevel(level);
- if (layerID==-1)
- return;
- const QObject* senderBox=sender();
+ int layerID = m_Doc->layerIDFromLevel(level);
+ if (layerID == -1)
+ return;
+ const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QCheckBox") == 0)
{
- m_Doc->setLayerVisible(layerID,((QCheckBox*)(senderBox))->isChecked());
+ bool isLayerVisible = ((QCheckBox*)(senderBox))->isChecked();
+ m_Doc->setLayerVisible(layerID, isLayerVisible);
+ if (!isLayerVisible)
+ m_Doc->m_Selection->removeItemsOfLayer(layerID);
setActiveLayer(Table->currentRow(), -1);
emit LayerChanged();
}
@@ -432,13 +436,13 @@
if (!m_Doc)
return;
int level = QString(sender()->objectName()).toInt();
- int layerID=m_Doc->layerIDFromLevel(level);
- if (layerID==-1)
- return;
- const QObject* senderBox=sender();
+ int layerID = m_Doc->layerIDFromLevel(level);
+ if (layerID == -1)
+ return;
+ const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QCheckBox") == 0)
{
- m_Doc->setLayerPrintable(layerID,((QCheckBox*)(senderBox))->isChecked());
+ m_Doc->setLayerPrintable(layerID, ((QCheckBox*)(senderBox))->isChecked());
setActiveLayer(Table->currentRow(), -1);
emit LayerChanged();
}
@@ -449,14 +453,17 @@
if (!m_Doc)
return;
int level = QString(sender()->objectName()).toInt();
- int layerID=m_Doc->layerIDFromLevel(level);
- if (layerID==-1)
- return;
- const QObject* senderBox=sender();
+ int layerID = m_Doc->layerIDFromLevel(level);
+ if (layerID == -1)
+ return;
+ const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QCheckBox") == 0)
{
- m_Doc->setLayerLocked(layerID,((QCheckBox*)(senderBox))->isChecked());
- deleteLayerButton->setEnabled(!((QCheckBox*)(senderBox))->isChecked());
+ bool isLayerLocked = ((QCheckBox*)(senderBox))->isChecked();
+ m_Doc->setLayerLocked(layerID, isLayerLocked);
+ if (isLayerLocked)
+ m_Doc->m_Selection->removeItemsOfLayer(layerID);
+ deleteLayerButton->setEnabled(!isLayerLocked);
setActiveLayer(Table->currentRow(), -1);
}
m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
@@ -467,13 +474,13 @@
if (!m_Doc)
return;
int level = QString(sender()->objectName()).toInt();
- int layerID=m_Doc->layerIDFromLevel(level);
- if (layerID==-1)
- return;
- const QObject* senderBox=sender();
+ int layerID = m_Doc->layerIDFromLevel(level);
+ if (layerID == -1)
+ return;
+ const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QCheckBox") == 0)
{
- m_Doc->setLayerFlow(layerID,((QCheckBox*)(senderBox))->isChecked());
+ m_Doc->setLayerFlow(layerID, ((QCheckBox*)(senderBox))->isChecked());
emit LayerChanged();
setActiveLayer(Table->currentRow(), -1);
}
@@ -484,13 +491,13 @@
if (!m_Doc)
return;
int level = QString(sender()->objectName()).toInt();
- int layerID=m_Doc->layerIDFromLevel(level);
- if (layerID==-1)
- return;
- const QObject* senderBox=sender();
+ int layerID = m_Doc->layerIDFromLevel(level);
+ if (layerID == -1)
+ return;
+ const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QCheckBox") == 0)
{
- m_Doc->setLayerOutline(layerID,((QCheckBox*)(senderBox))->isChecked());
+ m_Doc->setLayerOutline(layerID, ((QCheckBox*)(senderBox))->isChecked());
emit LayerChanged();
setActiveLayer(Table->currentRow(), -1);
}
@@ -501,13 +508,14 @@
if (!m_Doc)
return;
int level = QString(sender()->objectName()).toInt();
- int layerID=m_Doc->layerIDFromLevel(level);
- if (layerID==-1)
- return;
- const QObject* senderBox=sender();
+ int layerID = m_Doc->layerIDFromLevel(level);
+ if (layerID == -1)
+ return;
+ const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QCheckBox") == 0)
{
- m_Doc->setLayerSelectable(layerID,((QCheckBox*)(senderBox))->isChecked());
+ bool isLayerSelectable = ((QCheckBox*)(senderBox))->isChecked();
+ m_Doc->setLayerSelectable(layerID, isLayerSelectable);
emit LayerChanged();
setActiveLayer(Table->currentRow(), -1);
}
@@ -556,10 +564,10 @@
if (!m_Doc)
return;
int level = QString(sender()->objectName()).toInt();
- int layerID=m_Doc->layerIDFromLevel(level);
- if (layerID==-1)
- return;
- const QObject* senderBox=sender();
+ int layerID = m_Doc->layerIDFromLevel(level);
+ if (layerID == -1)
+ return;
+ const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QToolButton") == 0)
{
QColor neu = QColor();
@@ -601,18 +609,18 @@
disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
disconnect(Table, SIGNAL(cellClicked(int, int)), this, SLOT(setActiveLayer(int, int)));
- int layerToMark=layerID;
- if (layerID==-1)
- layerToMark=m_Doc->activeLayer();
+ int layerToMark = layerID;
+ if (layerID == -1)
+ layerToMark = m_Doc->activeLayer();
Table->setCurrentCell(m_Doc->layerCount()-1-m_Doc->layerLevelFromID(layerToMark), 6);
opacitySpinBox->setValue(qRound(m_Doc->layerTransparency(layerToMark) * 100));
blendMode->setCurrentIndex(m_Doc->layerBlendMode(layerToMark));
- deleteLayerButton->setEnabled(m_Doc->layerCount()>1 && !m_Doc->layerLocked( m_Doc->activeLayer() ));
+ deleteLayerButton->setEnabled(m_Doc->layerCount() > 1 && !m_Doc->layerLocked( m_Doc->activeLayer() ));
- if (layers->count()>1)
- {
- raiseLayerButton->setEnabled(Table->currentRow()!=0);
- lowerLayerButton->setEnabled(Table->currentRow()!=Table->rowCount()-1);
+ if (layers->count() > 1)
+ {
+ raiseLayerButton->setEnabled(Table->currentRow() != 0);
+ lowerLayerButton->setEnabled(Table->currentRow() != Table->rowCount() - 1);
}
else
{
@@ -635,15 +643,15 @@
}
disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
- int layerID=m_Doc->layerIDFromLevel(m_Doc->layerCount()-1-row);
+ int layerID = m_Doc->layerIDFromLevel(m_Doc->layerCount()-1-row);
bool found=m_Doc->setActiveLayer(layerID);
if (found)
{
m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
opacitySpinBox->setValue(qRound(m_Doc->layerTransparency(m_Doc->activeLayer()) * 100));
blendMode->setCurrentIndex(m_Doc->layerBlendMode(m_Doc->activeLayer()));
- deleteLayerButton->setEnabled(m_Doc->layerCount()>1 && !m_Doc->layerLocked( m_Doc->activeLayer() ));
- if (layers->count()>1)
+ deleteLayerButton->setEnabled(m_Doc->layerCount() > 1 && !m_Doc->layerLocked( m_Doc->activeLayer() ));
+ if (layers->count() > 1)
{
raiseLayerButton->setEnabled(Table->currentRow()!= 0);
lowerLayerButton->setEnabled(Table->currentRow()!= Table->rowCount()-1);
Modified: trunk/Scribus/scribus/ui/layers.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23175&path=/trunk/Scribus/scribus/ui/layers.h
==============================================================================
--- trunk/Scribus/scribus/ui/layers.h (original)
+++ trunk/Scribus/scribus/ui/layers.h Tue Sep 3 01:05:50 2019
@@ -61,7 +61,7 @@
void changeOpacity();
void changeBlendMode(int blend);
void setActiveLayer(int row, int col);
- void ClearInhalt();
+ void clearContent();
void markActiveLayer(int layerID=-1);
void languageChange();
Modified: trunk/Scribus/scribus/ui/outlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23175&path=/trunk/Scribus/scribus/ui/outlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/outlinepalette.cpp Tue Sep 3 01:05:50 2019
@@ -624,7 +624,10 @@
void OutlinePalette::setLayerVisible(int layerID)
{
- currDoc->setLayerVisible(layerID, !currDoc->layerVisible(layerID));
+ bool isLayerVisible = !currDoc->layerVisible(layerID);
+ currDoc->setLayerVisible(layerID, isLayerVisible);
+ if (!isLayerVisible)
+ currDoc->m_Selection->removeItemsOfLayer(layerID);
currDoc->scMW()->showLayer();
currDoc->scMW()->layerPalette->rebuildList();
currDoc->scMW()->layerPalette->markActiveLayer();
@@ -632,7 +635,10 @@
void OutlinePalette::setLayerLocked(int layerID)
{
- currDoc->setLayerLocked(layerID, !currDoc->layerLocked(layerID));
+ bool isLayerLocked = !currDoc->layerLocked(layerID);
+ currDoc->setLayerLocked(layerID, isLayerLocked);
+ if (isLayerLocked)
+ currDoc->m_Selection->removeItemsOfLayer(layerID);
currDoc->scMW()->layerPalette->rebuildList();
currDoc->scMW()->layerPalette->markActiveLayer();
}
More information about the scribus-commit
mailing list