GitLab Commit is coming up on August 3-4. Learn how to innovate together using GitLab, the DevOps platform. Register for free: gitlabcommitvirtual2021.com

Commit a35ae97e authored by Jean Ghali's avatar Jean Ghali
Browse files

#15798: prevent selection of items on invisible layers

git-svn-id: svn://scribus.net/trunk/Scribus@23174 11d20701-8431-0410-a711-e3c959e3b870
parent ef0707a5
......@@ -416,7 +416,7 @@ PageItem* Canvas::itemUnderCursor(QPoint globalPos, PageItem* itemAbove, bool al
{
currItem = m_doc->currentPage()->FromMaster.at(currNr);
QTransform itemPos;
if (((currItem->m_layerID == m_doc->activeLayer()) || (m_doc->layerSelectable(currItem->m_layerID))) && (!m_doc->layerLocked(currItem->m_layerID)))
if (m_doc->canSelectItemOnLayer(currItem->m_layerID))
{
if (!currItem->ChangedMasterItem)
{
......@@ -464,7 +464,7 @@ PageItem* Canvas::itemUnderCursor(QPoint globalPos, PageItem* itemAbove, bool al
--currNr;
continue;
}
if (((currItem->m_layerID == m_doc->activeLayer()) || (m_doc->layerSelectable(currItem->m_layerID))) && (!m_doc->layerLocked(currItem->m_layerID)))
if (m_doc->canSelectItemOnLayer(currItem->m_layerID))
{
QTransform itemPos = currItem->getTransform();
QPainterPath currPath(itemPos.map(QPointF(0,0)));
......
......@@ -888,7 +888,7 @@ void CanvasMode_Edit::mouseReleaseEvent(QMouseEvent *m)
QRect apr2(docItem->getRedrawBounding(1.0));
if ((m_doc->masterPageMode()) && (docItem->OnMasterPage != m_doc->currentPage()->pageName()))
continue;
if (((Sele.contains(apr.boundingRect())) || (Sele.contains(apr2))) && ((docItem->m_layerID == m_doc->activeLayer()) || (m_doc->layerSelectable(docItem->m_layerID))) && (!m_doc->layerLocked(docItem->m_layerID)))
if (((Sele.contains(apr.boundingRect())) || (Sele.contains(apr2))) && m_doc->canSelectItemOnLayer(docItem->m_layerID))
{
bool redrawSelection=false;
m_view->SelectItemNr(a, redrawSelection);
......
......@@ -1166,7 +1166,7 @@ void CanvasMode_Normal::mouseReleaseEvent(QMouseEvent *m)
PageItem* docItem = m_doc->Items->at(a);
if ((m_doc->masterPageMode()) && (docItem->OnMasterPage != m_doc->currentPage()->pageName()))
continue;
if (((docItem->m_layerID == m_doc->activeLayer()) || (m_doc->layerSelectable(docItem->m_layerID))) && (!m_doc->layerLocked(docItem->m_layerID)))
if (m_doc->canSelectItemOnLayer(docItem->m_layerID))
{
// get current item rect/bounding box
QRect apr2 = m_canvas->canvasToLocal( docItem->getCurrentBoundingRect(docItem->lineWidth()) );
......
......@@ -5111,12 +5111,12 @@ void ScribusMainWindow::SelectAll(bool docWideSelect)
PageItem *currItem;
view->Deselect();
doc->m_Selection->delaySignalsOn();
int docItemsCount=doc->Items->count();
int docCurrentPage=doc->currentPageNumber();
int docItemsCount = doc->Items->count();
int docCurrentPage = doc->currentPageNumber();
for (int i = 0; i < docItemsCount; ++i)
{
currItem = doc->Items->at(i);
if (((currItem->m_layerID == doc->activeLayer()) || (doc->layerSelectable(currItem->m_layerID))) && (!doc->layerLocked(currItem->m_layerID)))
if (doc->canSelectItemOnLayer(currItem->m_layerID))
{
if (docWideSelect)
doc->m_Selection->addItem(currItem);
......
......@@ -2871,7 +2871,7 @@ bool ScribusDoc::setActiveLayer(const int layerToActivate)
const ScLayer* ll = Layers.layerByID(layerToActivate);
Q_ASSERT(ll);
if (ll)
m_ActiveLayer=layerToActivate;
m_ActiveLayer = layerToActivate;
return (ll != nullptr);
}
 
......@@ -3395,11 +3395,22 @@ bool ScribusDoc::changeLayerName(const int layerID, const QString& newName)
return found;
}
 
bool ScribusDoc::canSelectItemOnLayer(int layerID) const
{
if ((m_ActiveLayer != layerID) && !layerSelectable(layerID))
return false;
bool canSelect = layerVisible(layerID);
if (!canSelect)
return false;
canSelect = !layerLocked(layerID);
return canSelect;
}
 
bool ScribusDoc::layerContainsItems(const int layerID)
bool ScribusDoc::layerContainsItems(const int layerID) const
{
QList<PageItem*> allItems;
int masterItemsCount=MasterItems.count();
int masterItemsCount = MasterItems.count();
for (int i = 0; i < masterItemsCount; ++i)
{
PageItem* currItem = MasterItems.at(i);
......@@ -3415,7 +3426,8 @@ bool ScribusDoc::layerContainsItems(const int layerID)
}
allItems.clear();
}
int docItemsCount=DocItems.count();
int docItemsCount = DocItems.count();
for (int i = 0; i < docItemsCount; ++i)
{
PageItem* currItem = DocItems.at(i);
......
......@@ -485,12 +485,22 @@ public:
* @return Success or failure
*/
bool changeLayerName(const int layerID, const QString& newName);
/**
* @brief Test if items can be selected on a specific layer
*
* This function check if items can be selected on the specified layer
* by checking layer visibility and selectable property etc...
*
* @param layerID ID of the layer
* @return a boolean
*/
bool canSelectItemOnLayer(int layerID) const;
/**
* @brief Does the layer have items on it?
* @param layerID ID of the layer
* @return Layer contains items bool
*/
bool layerContainsItems(const int layerID);
bool layerContainsItems(const int layerID) const;
/**
* @brief Renumber a layer. Used in particular for reinsertion for undo/redo
* @param layerID old layer ID
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment