r19527 by jghali - #12719 : improve behavior when changing layer selection

scribus-commit scribus-commit at lists.scribus.net
Tue Sep 23 10:09:25 UTC 2014


Author: jghali
Date: Tue Sep 23 10:09:25 2014
New Revision: 19527

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19527
Log:
#12719 : improve behavior when changing layer selection

Modified:
    branches/Version14x/Scribus/scribus/extimageprops.cpp
    branches/Version14x/Scribus/scribus/extimageprops.h

Modified: branches/Version14x/Scribus/scribus/extimageprops.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19527&path=/branches/Version14x/Scribus/scribus/extimageprops.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/extimageprops.cpp (original)
+++ branches/Version14x/Scribus/scribus/extimageprops.cpp Tue Sep 23 10:09:25 2014
@@ -131,6 +131,7 @@
 		layerTable->setHorizontalHeaderItem(0, new QTableWidgetItem(QIcon(loadIcon("16/show-object.png")), ""));
 		layerTable->setHorizontalHeaderItem(1, new QTableWidgetItem(""));
 		layerTable->setHorizontalHeaderItem(2, new QTableWidgetItem( tr("Name")));
+		layerTable->setSelectionBehavior(QTableWidget::SelectRows);
 		QHeaderView* headerH = layerTable->horizontalHeader();
 		headerH->setStretchLastSection(true);
 		headerH->setMovable(false);
@@ -297,7 +298,7 @@
 		layerTable->selectionModel()->clearSelection();
 		opacitySpinBox->setEnabled(false);
 		blendMode->setEnabled(false);
-		connect(layerTable, SIGNAL(cellClicked(int, int)), this, SLOT(selLayer(int)));
+		connect(layerTable, SIGNAL(itemSelectionChanged()), this, SLOT(selLayer()));
 		connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changedLayer()));
 		connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
 	}
@@ -383,22 +384,28 @@
 	currentItem->pixm.imgInfo.isRequest = true;
 	for (int r = 0; r < layerTable->rowCount(); ++r)
 	{
-		if (currentLayer == layerTable->rowCount() - r - 1)
+		int layerIndex = layerTable->rowCount() - r - 1;
+		if (currentLayer == layerIndex)
 		{
 			loadingInfo.blend = blendModesRev[blendMode->currentText()];
 			loadingInfo.opacity = qRound(opacitySpinBox->value() / 100.0 * 255);
 		}
+		else if (currentItem->pixm.imgInfo.RequestProps.contains(layerIndex))
+		{
+			loadingInfo.blend = currentItem->pixm.imgInfo.RequestProps[layerIndex].blend;
+			loadingInfo.opacity = currentItem->pixm.imgInfo.RequestProps[layerIndex].opacity;
+		}
 		else
 		{
-			loadingInfo.blend = currentItem->pixm.imgInfo.layerInfo[layerTable->rowCount() - r - 1].blend;
-			loadingInfo.opacity = currentItem->pixm.imgInfo.layerInfo[layerTable->rowCount() - r - 1].opacity;
-		}
-		loadingInfo.visible = FlagsSicht.at(layerTable->rowCount() - r - 1)->isChecked();
-		if (FlagsMask.at(layerTable->rowCount() - r - 1))
-			loadingInfo.useMask = FlagsMask.at(layerTable->rowCount() - r - 1)->isChecked();
+			loadingInfo.blend = currentItem->pixm.imgInfo.layerInfo[layerIndex].blend;
+			loadingInfo.opacity = currentItem->pixm.imgInfo.layerInfo[layerIndex].opacity;
+		}
+		loadingInfo.visible = FlagsSicht.at(layerIndex)->isChecked();
+		if (FlagsMask.at(layerIndex))
+			loadingInfo.useMask = FlagsMask.at(layerIndex)->isChecked();
 		else
 			loadingInfo.useMask = true;
-		currentItem->pixm.imgInfo.RequestProps.insert(layerTable->rowCount() - r - 1, loadingInfo);
+		currentItem->pixm.imgInfo.RequestProps.insert(layerIndex, loadingInfo);
 	}
 	if (doPreview)
 	{
@@ -407,23 +414,34 @@
 	}
 }
 
-void ExtImageProps::selLayer(int layer)
-{
+void ExtImageProps::selLayer()
+{
+	QModelIndexList selectedRows = layerTable->selectionModel()->selectedRows();
+	if (selectedRows.count() <= 0)
+	{
+		currentLayer = -1;
+		opacitySpinBox->setEnabled(false);
+		blendMode->setEnabled(false);
+		return;
+	}
+
+	int selectedRow = selectedRows.at(0).row();
+	currentLayer = layerTable->rowCount() - selectedRow - 1;
+
 	disconnect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changedLayer()));
 	disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
-	if ((currentItem->pixm.imgInfo.isRequest) && (currentItem->pixm.imgInfo.RequestProps.contains(layerTable->rowCount() - layer - 1)))
-	{
-		opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.RequestProps[layerTable->rowCount() - layer - 1].opacity / 255.0 * 100));
-		setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.RequestProps[layerTable->rowCount() - layer - 1].blend]);
+	if ((currentItem->pixm.imgInfo.isRequest) && (currentItem->pixm.imgInfo.RequestProps.contains(currentLayer)))
+	{
+		opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.RequestProps[currentLayer].opacity / 255.0 * 100));
+		setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.RequestProps[currentLayer].blend]);
 	}
 	else
 	{
-		opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.layerInfo[layerTable->rowCount() - layer - 1].opacity / 255.0 * 100));
-		setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.layerInfo[layerTable->rowCount() - layer - 1].blend]);
+		opacitySpinBox->setValue(qRound(currentItem->pixm.imgInfo.layerInfo[currentLayer].opacity / 255.0 * 100));
+		setCurrentComboItem(blendMode, blendModes[currentItem->pixm.imgInfo.layerInfo[currentLayer].blend]);
 	}
 	opacitySpinBox->setEnabled(true);
 	blendMode->setEnabled(true);
-	currentLayer = layerTable->rowCount() - layer - 1;
 	connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(changedLayer()));
 	connect(blendMode, SIGNAL(activated(int)), this, SLOT(changedLayer()));
 }

Modified: branches/Version14x/Scribus/scribus/extimageprops.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19527&path=/branches/Version14x/Scribus/scribus/extimageprops.h
==============================================================================
--- branches/Version14x/Scribus/scribus/extimageprops.h (original)
+++ branches/Version14x/Scribus/scribus/extimageprops.h Tue Sep 23 10:09:25 2014
@@ -65,7 +65,7 @@
 	void leaveCancel();
 	void changePreview();
 	void changedLayer();
-	void selLayer(int layer);
+	void selLayer();
 	void selPath(QListWidgetItem *c);
 	void noPath();
 




More information about the scribus-commit mailing list