some more legend fixes

git-svn-id: http://svn.osgeo.org/qgis/trunk@4353 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2005-12-17 14:23:26 +00:00
parent f97e9faf72
commit 78e3a756bd
4 changed files with 48 additions and 38 deletions

View File

@ -51,11 +51,6 @@ QgsLegend::QgsLegend(QgisApp* app, QWidget * parent, const char *name)
{
connect( this, SIGNAL(selectionChanged(QTreeWidgetItem *)),
this, SLOT(updateLegendItem(QTreeWidgetItem *)) );
connect( this, SIGNAL(doubleClicked(QTreeWidgetItem *, const QPoint &, int)),
this, SLOT(handleDoubleClickEvent(QTreeWidgetItem*)));
//just for a test
connect( this, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
this, SLOT(handleItemChange(QTreeWidgetItem*, int)));
@ -212,9 +207,12 @@ void QgsLegend::mouseMoveEvent(QMouseEvent * e)
qWarning("mouseMoveEvent::INSERT");
#endif
setCursor( QCursor(Qt::PointingHandCursor) );
removeItem(origin);
dest->insert(origin, false);
setCurrentItem(origin);
if(origin->parent() != dest)
{
removeItem(origin);
dest->insert(origin, false);
setCurrentItem(origin);
}
}
else//no action
{
@ -321,35 +319,50 @@ void QgsLegend::mouseReleaseEvent(QMouseEvent * e)
mItemBeingMoved = NULL;
}
void QgsLegend::handleDoubleClickEvent(QTreeWidgetItem* item)
void QgsLegend::mouseDoubleClickEvent(QMouseEvent* e)
{
#if 0
QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(item);
QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(currentItem());
QgsMapLayer* ml = 0;
if(li)
{
if(li->type() == QgsLegendItem::LEGEND_LAYER_FILE)
{
QgsLegendLayerFile* llf = dynamic_cast<QgsLegendLayerFile*>(li);
if(llf)
{
QgsMapLayer* ml = llf->layer();
if (ml && ml->type() == QgsMapLayer::RASTER)
{
QgsRasterLayerProperties *rlp = new QgsRasterLayerProperties(ml);
if (rlp->exec())
{
delete rlp;
QCoreApplication::processEvents();
}
}
else if(ml) //vector
{
ml->showLayerProperties();
}
}
QgsLegendLayerFile* llf = dynamic_cast<QgsLegendLayerFile*>(li);
ml = llf->layer();
}
else if(li->type() == QgsLegendItem::LEGEND_LAYER)
{
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(li);
ml = ll->firstMapLayer();
}
if (ml && ml->type() == QgsMapLayer::RASTER)
{
QgsRasterLayerProperties *rlp = new QgsRasterLayerProperties(ml);
if (rlp->exec())
{
delete rlp;
QCoreApplication::processEvents();
}
}
else if(ml) //vector
{
ml->showLayerProperties();
}
}
}
void QgsLegend::keyPressEvent(QKeyEvent* e)
{
if(e->key() == Qt::Key_Return)
{
QTreeWidgetItem* item = currentItem();
if(item)
{
closePersistentEditor(item, 0);
}
}
#endif
}
void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& position)

View File

@ -203,7 +203,8 @@ protected:
* @return void
*/
void mouseReleaseEvent(QMouseEvent * e);
void mouseDoubleClickEvent(QMouseEvent* e);
void keyPressEvent(QKeyEvent* e);
/**Stores the necessary information about the position of an item in the hierarchy. Afterwards,
this item may be moved back to the original position with resetToInitialPosition()*/
void storeInitialPosition(QTreeWidgetItem* li);
@ -213,8 +214,6 @@ this item may be moved back to the original position with resetToInitialPosition
private slots:
/**Calls 'handleDoubleClickEvent' on the item*/
void handleDoubleClickEvent(QTreeWidgetItem* item);
/**Calls 'handleRightClickEvent' on the item*/
void handleRightClickEvent(QTreeWidgetItem* item, const QPoint& position);
/**Removes the current legend group*/

View File

@ -46,7 +46,7 @@ QgsLegendItem::DRAG_ACTION QgsLegendLayerFileGroup::accept(const QgsLegendItem*
if(li)
{
LEGEND_ITEM_TYPE type = li->type();
if ( type == LEGEND_LAYER_FILE && this != li->parent())
if ( type == LEGEND_LAYER_FILE /*&& this != li->parent()*/)
{
if(child(0) == 0)
{

View File

@ -70,14 +70,13 @@ int QgsLegendSymbologyGroup::compare (QTreeWidgetItem * i,int col, bool ascendin
void QgsLegendSymbologyGroup::updateLayerSymbologySettings(const QgsMapLayer* thelayer)
{
#if 0
//find the legend layer group node
QTreeWidgetItem* parent = this->parent();
QgsLegendItem* parent = dynamic_cast<QgsLegendItem*>(this->parent());
if(!parent)
{
return;
}
QTreeWidgetItem* sibling = 0;
QgsLegendItem* sibling = 0;
QgsLegendLayerFileGroup* group = 0;
for(sibling = parent->firstChild(); sibling != 0; sibling = sibling->nextSibling())
{
@ -108,5 +107,4 @@ void QgsLegendSymbologyGroup::updateLayerSymbologySettings(const QgsMapLayer* th
}
}
}
#endif
}