Skip to content

Commit

Permalink
better method to check if a canvas redraw is necessary after a drag i…
Browse files Browse the repository at this point in the history
…n the legend

git-svn-id: http://svn.osgeo.org/qgis/trunk@4934 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 1, 2006
1 parent dd657c9 commit 25789d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/legend/qgslegend.cpp
Expand Up @@ -242,7 +242,6 @@ void QgsLegend::mouseMoveEvent(QMouseEvent * e)
}
}
}
//QTreeWidget::mouseMoveEvent(e);
}

void QgsLegend::mouseReleaseEvent(QMouseEvent * e)
Expand Down Expand Up @@ -325,7 +324,13 @@ void QgsLegend::mouseReleaseEvent(QMouseEvent * e)
origLayer->setLegend((QgsLegend*)(dynamic_cast<QgsLegendItem*>(dest->parent())->nextSibling()));
}
}
emit zOrderChanged(this);

std::deque<QString> layersAfterRelease = layerIDs(); //test if canvas redraw is really necessary
if(layersAfterRelease != mLayersPriorToMove)
{
emit zOrderChanged(this);
}

}
}
mMousePressedFlag = false;
Expand Down Expand Up @@ -989,6 +994,7 @@ void QgsLegend::storeInitialPosition(QTreeWidgetItem* li)
mRestoreInformation = YOUNGER_SIBLING;
mRestoreItem = ((QgsLegendItem*)(li))->findYoungerSibling();
}
mLayersPriorToMove = layerIDs();
}

void QgsLegend::resetToInitialPosition(QTreeWidgetItem* li)
Expand Down
5 changes: 5 additions & 0 deletions src/legend/qgslegend.h
Expand Up @@ -222,6 +222,7 @@ this item may be moved back to the original position with resetToInitialPosition
/**Returns the legend layer to which a map layer gelongs*/
QgsLegendLayer* findLegendLayer(const QString& layerKey);


private slots:

/**Calls 'handleRightClickEvent' on the item*/
Expand Down Expand Up @@ -294,6 +295,10 @@ this item may be moved back to the original position with resetToInitialPosition

bool mShowLegendLayerFiles;

/**Stores the layer ordering before a mouse Move. After the move, this is used to
decide if the mapcanvas really has to be refreshed*/
std::deque<QString> mLayersPriorToMove;

/*!
* A fuction sed to determin how far down in the list an item is (starting with one for the first Item.
*If the item is not in the legend, -1 is returned
Expand Down

0 comments on commit 25789d8

Please sign in to comment.