r17454 by fschmid - Added a checkbox to the layer palette to control the ability to select objects on layers.
scribus-commit
scribus-commit at lists.scribus.net
Tue Apr 17 20:11:05 UTC 2012
Author: fschmid
Date: Tue Apr 17 20:11:05 2012
New Revision: 17454
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17454
Log:
Added a checkbox to the layer palette to control the ability to select objects on layers.
Objects on the active layer are always selectable unless they are locked.
This should resolve bugs 10673 and 8631.
Modified:
trunk/Scribus/scribus/canvas.cpp
trunk/Scribus/scribus/canvasmode_edit.cpp
trunk/Scribus/scribus/canvasmode_normal.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
trunk/Scribus/scribus/sclayer.cpp
trunk/Scribus/scribus/sclayer.h
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusdoc.h
trunk/Scribus/scribus/ui/contextmenu.cpp
trunk/Scribus/scribus/ui/layers.cpp
trunk/Scribus/scribus/ui/layers.h
Modified: trunk/Scribus/scribus/canvas.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/canvas.cpp
==============================================================================
--- trunk/Scribus/scribus/canvas.cpp (original)
+++ trunk/Scribus/scribus/canvas.cpp Tue Apr 17 20:11:05 2012
@@ -432,7 +432,7 @@
{
currItem = m_doc->currentPage()->FromMaster.at(currNr);
QTransform itemPos;
- if ((currItem->LayerID == m_doc->activeLayer()) && (!m_doc->layerLocked(currItem->LayerID)))
+ if (((currItem->LayerID == m_doc->activeLayer()) || (m_doc->layerSelectable(currItem->LayerID))) && (!m_doc->layerLocked(currItem->LayerID)))
{
if (!currItem->ChangedMasterItem)
{
@@ -475,7 +475,7 @@
--currNr;
continue;
}
- if ((currItem->LayerID == m_doc->activeLayer()) && (!m_doc->layerLocked(currItem->LayerID)))
+ if (((currItem->LayerID == m_doc->activeLayer()) || (m_doc->layerSelectable(currItem->LayerID))) && (!m_doc->layerLocked(currItem->LayerID)))
{
QTransform itemPos = currItem->getTransform();
QPainterPath currPath(itemPos.map(QPointF(0,0)));
Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Tue Apr 17 20:11:05 2012
@@ -821,7 +821,7 @@
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->LayerID == m_doc->activeLayer()) && (!m_doc->layerLocked(docItem->LayerID)))
+ if (((Sele.contains(apr.boundingRect())) || (Sele.contains(apr2))) && ((docItem->LayerID == m_doc->activeLayer()) || (m_doc->layerSelectable(docItem->LayerID))) && (!m_doc->layerLocked(docItem->LayerID)))
{
bool redrawSelection=false;
m_view->SelectItemNr(a, redrawSelection);
Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp Tue Apr 17 20:11:05 2012
@@ -1022,7 +1022,7 @@
if ((m_doc->masterPageMode()) && (docItem->OnMasterPage != m_doc->currentPage()->pageName()))
continue;
QRect apr2 = m_canvas->canvasToLocal( docItem->getCurrentBoundingRect(docItem->lineWidth()) );
- if ((localSele.contains(apr2)) && (docItem->LayerID == m_doc->activeLayer()) && (!m_doc->layerLocked(docItem->LayerID)))
+ if ((localSele.contains(apr2)) && ((docItem->LayerID == m_doc->activeLayer()) || (m_doc->layerSelectable(docItem->LayerID))) && (!m_doc->layerLocked(docItem->LayerID)))
{
bool redrawSelection=false;
m_view->SelectItemNr(a, redrawSelection);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Tue Apr 17 20:11:05 2012
@@ -2790,6 +2790,7 @@
layer.isPrintable = attrs.valueAsInt("DRUCKEN");
layer.isEditable = attrs.valueAsInt("EDIT", 1);
layer.flowControl = attrs.valueAsInt("FLOW", 1);
+ layer.isSelectable = attrs.valueAsInt("SELECT", 0);
layer.transparency = attrs.valueAsDouble("TRANS", 1.0);
layer.blendMode = attrs.valueAsInt("BLEND", 0);
layer.outlineMode = attrs.valueAsInt("OUTL", 0);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Tue Apr 17 20:11:05 2012
@@ -975,6 +975,7 @@
docu.writeAttribute("SICHTBAR", static_cast<int>(m_Doc->Layers[lay].isViewable));
docu.writeAttribute("DRUCKEN", static_cast<int>(m_Doc->Layers[lay].isPrintable));
docu.writeAttribute("EDIT", static_cast<int>(m_Doc->Layers[lay].isEditable));
+ docu.writeAttribute("SELECT", static_cast<int>(m_Doc->Layers[lay].isSelectable));
docu.writeAttribute("FLOW", static_cast<int>(m_Doc->Layers[lay].flowControl));
docu.writeAttribute("TRANS", m_Doc->Layers[lay].transparency);
docu.writeAttribute("BLEND", m_Doc->Layers[lay].blendMode);
Modified: trunk/Scribus/scribus/sclayer.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/sclayer.cpp
==============================================================================
--- trunk/Scribus/scribus/sclayer.cpp (original)
+++ trunk/Scribus/scribus/sclayer.cpp Tue Apr 17 20:11:05 2012
@@ -19,6 +19,7 @@
isPrintable = true;
isViewable = true;
isEditable = true;
+ isSelectable = false;
flowControl = true;
outlineMode = false;
transparency = 1.0;
@@ -34,6 +35,7 @@
isPrintable = true;
isViewable = true;
isEditable = true;
+ isSelectable = false;
flowControl = true;
outlineMode = false;
transparency = 1.0;
@@ -131,7 +133,8 @@
layer.isViewable = ll.isViewable;
layer.isPrintable = ll.isPrintable;
layer.isEditable = ll.isEditable;
- layer.ID = ll.ID;
+ layer.isSelectable = ll.isSelectable;
+ layer.ID = ll.ID;
layer.Name = ll.Name;
layer.flowControl = ll.flowControl;
layer.transparency = ll.transparency;
@@ -634,6 +637,25 @@
return false;
}
+bool ScLayers::layerSelectable(const int layerID) const
+{
+ const ScLayer* layer = layerByID(layerID);
+ if (layer)
+ return layer->isSelectable;
+ return false;
+}
+
+bool ScLayers::setLayerSelectable(const int layerID, const bool isSelectable)
+{
+ ScLayer* layer = byID(layerID);
+ if (layer)
+ {
+ layer->isSelectable = isSelectable;
+ return true;
+ }
+ return false;
+}
+
uint qHash(const ScLayer& layer)
{
return qHash(&layer);
Modified: trunk/Scribus/scribus/sclayer.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/sclayer.h
==============================================================================
--- trunk/Scribus/scribus/sclayer.h (original)
+++ trunk/Scribus/scribus/sclayer.h Tue Apr 17 20:11:05 2012
@@ -25,6 +25,7 @@
bool isPrintable;
bool isViewable;
bool isEditable;
+ bool isSelectable;
bool flowControl;
bool outlineMode;
double transparency;
@@ -322,6 +323,21 @@
* @return Success or failure
*/
bool setLayerMarker(const int layerID, QColor color);
+
+ /**
+ * @brief are objects on the layer selectable
+ * @param layerID ID of the layer
+ * @return Items selectable or not
+ */
+ bool layerSelectable(const int layerID) const;
+
+ /**
+ * @brief Set objects on the layer selectable via the layer ID
+ * @param layerID ID of the layer
+ * @param isSelectable true = layer objects are selectable
+ * @return bool Success or failure
+ */
+ bool setLayerSelectable(const int layerID, const bool isSelectable);
};
uint qHash(const ScLayer& layer);
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Apr 17 20:11:05 2012
@@ -2590,6 +2590,38 @@
return false;
}
+bool ScribusDoc::setLayerSelectable(const int layerID, const bool isSelectable)
+{
+ ScLayers::iterator itend=Layers.end();
+ ScLayers::iterator it;
+ bool found=false;
+ for (it = Layers.begin(); it != itend; ++it)
+ {
+ if (it->ID == layerID)
+ {
+ it->isSelectable = isSelectable;
+ found=true;
+ break;
+ }
+ }
+ if (found)
+ changed();
+ return found;
+}
+
+
+bool ScribusDoc::layerSelectable(const int layerID)
+{
+ ScLayers::iterator itend=Layers.end();
+ ScLayers::iterator it;
+ for (it = Layers.begin(); it != itend; ++it)
+ {
+ if (it->ID == layerID)
+ return it->isSelectable;
+ }
+ return false;
+}
+
bool ScribusDoc::setLayerLocked(const int layerID, const bool isLocked)
{
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Tue Apr 17 20:11:05 2012
@@ -352,6 +352,19 @@
* @return Visible or not
*/
bool layerVisible(const int layerID);
+ /**
+ * @brief are objects on the layer selectable
+ * @param layerID ID of the layer
+ * @return Items selectable or not
+ */
+ bool layerSelectable(const int layerID);
+ /**
+ * @brief Set objects on the layer selectable via the layer ID
+ * @param layerID ID of the layer
+ * @param isSelectable true = layer objects are selectable
+ * @return bool Success or failure
+ */
+ bool setLayerSelectable(const int layerID, const bool isSelectable);
/**
* @brief Set the layer locked via the layer number
* @param layerID ID of the layer
Modified: trunk/Scribus/scribus/ui/contextmenu.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/ui/contextmenu.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/contextmenu.cpp (original)
+++ trunk/Scribus/scribus/ui/contextmenu.cpp Tue Apr 17 20:11:05 2012
@@ -344,12 +344,13 @@
//<-- Add Groups Items
if (selectedItemCount > 1)
{
- addAction(m_AP->scrActions["itemGroup"]);
+ if (m_Sel.objectsLayer() != -1)
+ addAction(m_AP->scrActions["itemGroup"]);
}
else
{
if (currItem->isGroup())
- addAction(m_AP->scrActions["itemUngroup"]);
+ addAction(m_AP->scrActions["itemUngroup"]);
}
//-->
Modified: trunk/Scribus/scribus/ui/layers.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/ui/layers.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/layers.cpp (original)
+++ trunk/Scribus/scribus/ui/layers.cpp Tue Apr 17 20:11:05 2012
@@ -66,14 +66,15 @@
layout1->addWidget( opacitySpinBox );
LayerPaletteLayout->addLayout( layout1 );
- Table = new QTableWidget(0, 7, this );
+ Table = new QTableWidget(0, 8, this );
Table->setHorizontalHeaderItem(0, new QTableWidgetItem(""));
Table->setHorizontalHeaderItem(1, new QTableWidgetItem(QIcon(loadIcon("16/show-object.png")), ""));
Table->setHorizontalHeaderItem(2, new QTableWidgetItem(QIcon(loadIcon("16/document-print.png")), ""));
Table->setHorizontalHeaderItem(3, new QTableWidgetItem(QIcon(loadIcon("16/lock.png")), ""));
Table->setHorizontalHeaderItem(4, new QTableWidgetItem(QIcon(loadIcon("16/layer-flow-around.png")), ""));
Table->setHorizontalHeaderItem(5, new QTableWidgetItem(QIcon(loadIcon("layer-outline.png")), ""));
- Table->setHorizontalHeaderItem(6, new QTableWidgetItem( tr("Name")));
+ Table->setHorizontalHeaderItem(6, new QTableWidgetItem(QIcon(loadIcon("16/pointer.png")), ""));
+ Table->setHorizontalHeaderItem(7, new QTableWidgetItem( tr("Name")));
QHeaderView *header = Table->horizontalHeader();
header->setStretchLastSection(true);
@@ -88,6 +89,7 @@
Table->setColumnWidth(3, 24);
Table->setColumnWidth(4, 24);
Table->setColumnWidth(5, 24);
+ Table->setColumnWidth(6, 24);
Table->setSortingEnabled(false);
Table->setSelectionBehavior( QAbstractItemView::SelectRows );
QHeaderView *Header = Table->verticalHeader();
@@ -250,7 +252,12 @@
connect(cp5, SIGNAL(clicked()), this, SLOT(outlineToggleLayer()));
Table->setCellWidget(row, 5, cp5);
cp5->setChecked(m_Doc->layerOutline(layerID));
- Table->setItem(row, 6, new QTableWidgetItem(m_Doc->layerName(layerID)));
+ QCheckBox *cp6 = new QCheckBox(this);
+ cp6->setObjectName(tmp);
+ connect(cp6, SIGNAL(clicked()), this, SLOT(selectToggleLayer()));
+ Table->setCellWidget(row, 6, cp6);
+ cp6->setChecked(m_Doc->layerSelectable(layerID));
+ Table->setItem(row, 7, new QTableWidgetItem(m_Doc->layerName(layerID)));
}
connect(Table, SIGNAL(cellChanged(int, int)), this, SLOT(changeName(int, int)));
connect(Table, SIGNAL(cellClicked(int, int)), this, SLOT(setActiveLayer(int, int)));
@@ -340,7 +347,7 @@
void LayerPalette::changeName(int row, int col)
{
- if (col == 6)
+ if (col == 7)
{
int layerLevel = m_Doc->layerCount()-1-row;
int layerID=m_Doc->layerIDFromLevel(layerLevel);
@@ -420,6 +427,21 @@
if (strcmp(senderBox->metaObject()->className(), "QCheckBox") == 0)
{
m_Doc->setLayerOutline(layerID,((QCheckBox*)(senderBox))->isChecked());
+ emit LayerChanged();
+ setActiveLayer(Table->currentRow(), -1);
+ }
+}
+
+void LayerPalette::selectToggleLayer()
+{
+ int level = QString(sender()->objectName()).toInt();
+ 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());
emit LayerChanged();
setActiveLayer(Table->currentRow(), -1);
}
@@ -529,7 +551,7 @@
void LayerPalette::setActiveLayer(int row, int col)
{
- if (col != 6)
+ if (col != 7)
{
markActiveLayer(-1);
return;
@@ -613,7 +635,8 @@
Table->horizontalHeaderItem(3)->setToolTip("<qt>" + tr("Lock or Unlock Layer - Unchecked is unlocked ") + "</qt>" );
Table->horizontalHeaderItem(4)->setToolTip("<qt>" + tr("Make text in lower layers flow around objects - Enabling this forces text in lower layers to flow around objects of the layer for which this option has been enabled") + "</qt>" );
Table->horizontalHeaderItem(5)->setToolTip("<qt>" + tr("Outline Mode - Toggles the 'wireframe' display of objects to speed the display of very complex objects.") + "</qt>" ) ;
- Table->horizontalHeaderItem(6)->setToolTip("<qt>" + tr("Name of the Layer - Double click on the name of a layer to edit the name") + "</qt>" );
-}
-
-
+ Table->horizontalHeaderItem(6)->setToolTip("<qt>" + tr("Select Objects on Layer - Check to enable selecting. ") + "</qt>" );
+ Table->horizontalHeaderItem(7)->setToolTip("<qt>" + tr("Name of the Layer - Double click on the name of a layer to edit the name") + "</qt>" );
+}
+
+
Modified: trunk/Scribus/scribus/ui/layers.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17454&path=/trunk/Scribus/scribus/ui/layers.h
==============================================================================
--- trunk/Scribus/scribus/ui/layers.h (original)
+++ trunk/Scribus/scribus/ui/layers.h Tue Apr 17 20:11:05 2012
@@ -56,6 +56,7 @@
void lockLayer();
void flowToggleLayer();
void outlineToggleLayer();
+ void selectToggleLayer();
void toggleAllfromHeader(int index);
void markLayer();
void changeOpacity();
More information about the scribus-commit
mailing list