[QGIS Commit] r8912 -
branches/advanced_printing_branch/src/app/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Jul 26 03:26:04 EDT 2008
Author: mhugent
Date: 2008-07-26 03:26:02 -0400 (Sat, 26 Jul 2008)
New Revision: 8912
Modified:
branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp
Log:
Possibility to also move layers up/down the composer legend
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp 2008-07-25 23:59:41 UTC (rev 8911)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp 2008-07-26 07:26:02 UTC (rev 8912)
@@ -225,20 +225,26 @@
}
QModelIndex parentIndex = currentIndex.parent();
- if(!parentIndex.isValid())
+ QList<QStandardItem*> itemToMove;
+ QList<QStandardItem*> youngerSiblingItem;
+
+ if(!parentIndex.isValid()) //move toplevel (layer) item
{
- return;
+ youngerSiblingItem = itemModel->takeRow(row + 1);
+ itemToMove = itemModel->takeRow(row);
+ itemModel->insertRow(row, youngerSiblingItem);
+ itemModel->insertRow(row + 1, itemToMove);
}
+ else //move child (classification) item
+ {
+ QStandardItem* parentItem = itemModel->itemFromIndex(parentIndex);
+ youngerSiblingItem = parentItem->takeRow(row + 1);
+ itemToMove = parentItem->takeRow(row);
+ parentItem->insertRow(row, youngerSiblingItem);
+ parentItem->insertRow(row + 1, itemToMove);
+ }
- //exchange the items
- QStandardItem* parentItem = itemModel->itemFromIndex(parentIndex);
- QList<QStandardItem*> youngerSiblingItem = parentItem->takeRow(row + 1);
- QList<QStandardItem*> itemToMove = parentItem->takeRow(row);
-
- parentItem->insertRow(row, youngerSiblingItem);
- parentItem->insertRow(row + 1, itemToMove);
mItemTreeView->setCurrentIndex(itemModel->indexFromItem(itemToMove.at(0)));
-
if(mLegend)
{
mLegend->update();
@@ -269,20 +275,27 @@
}
QModelIndex parentIndex = currentIndex.parent();
- if(!parentIndex.isValid())
+ QList<QStandardItem*> itemToMove;
+ QList<QStandardItem*> olderSiblingItem;
+
+ if(!parentIndex.isValid()) //move toplevel item
{
- return;
+ itemToMove = itemModel->takeRow(row);
+ olderSiblingItem = itemModel->takeRow(row - 1);
+ itemModel->insertRow(row - 1, itemToMove);
+ itemModel->insertRow(row, olderSiblingItem);
+
}
-
- //exchange the items
- QStandardItem* parentItem = itemModel->itemFromIndex(parentIndex);
- QList<QStandardItem*> itemToMove = parentItem->takeRow(row);
- QList<QStandardItem*> olderSiblingItem = parentItem->takeRow(row - 1);
-
- parentItem->insertRow(row - 1, itemToMove);
- parentItem->insertRow(row, olderSiblingItem);
+ else //move classification items
+ {
+ QStandardItem* parentItem = itemModel->itemFromIndex(parentIndex);
+ itemToMove = parentItem->takeRow(row);
+ olderSiblingItem = parentItem->takeRow(row - 1);
+ parentItem->insertRow(row - 1, itemToMove);
+ parentItem->insertRow(row, olderSiblingItem);
+ }
+
mItemTreeView->setCurrentIndex(itemModel->indexFromItem(itemToMove.at(0)));
-
if(mLegend)
{
mLegend->update();
More information about the QGIS-commit
mailing list