Skip to content

Commit

Permalink
some more legend fixes
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4353 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Dec 17, 2005
1 parent 419926f commit 82089e5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 38 deletions.
73 changes: 43 additions & 30 deletions src/legend/qgslegend.cpp
Expand Up @@ -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)));
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions src/legend/qgslegend.h
Expand Up @@ -203,7 +203,8 @@ public slots:
* @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);
Expand All @@ -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*/
Expand Down
2 changes: 1 addition & 1 deletion src/legend/qgslegendlayerfilegroup.cpp
Expand Up @@ -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)
{
Expand Down
6 changes: 2 additions & 4 deletions src/legend/qgslegendsymbologygroup.cpp
Expand Up @@ -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())
{
Expand Down Expand Up @@ -108,5 +107,4 @@ void QgsLegendSymbologyGroup::updateLayerSymbologySettings(const QgsMapLayer* th
}
}
}
#endif
}

0 comments on commit 82089e5

Please sign in to comment.