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

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

View File

@ -203,7 +203,8 @@ protected:
* @return void * @return void
*/ */
void mouseReleaseEvent(QMouseEvent * e); 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, /**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()*/ this item may be moved back to the original position with resetToInitialPosition()*/
void storeInitialPosition(QTreeWidgetItem* li); void storeInitialPosition(QTreeWidgetItem* li);
@ -213,8 +214,6 @@ this item may be moved back to the original position with resetToInitialPosition
private slots: private slots:
/**Calls 'handleDoubleClickEvent' on the item*/
void handleDoubleClickEvent(QTreeWidgetItem* item);
/**Calls 'handleRightClickEvent' on the item*/ /**Calls 'handleRightClickEvent' on the item*/
void handleRightClickEvent(QTreeWidgetItem* item, const QPoint& position); void handleRightClickEvent(QTreeWidgetItem* item, const QPoint& position);
/**Removes the current legend group*/ /**Removes the current legend group*/

View File

@ -46,7 +46,7 @@ QgsLegendItem::DRAG_ACTION QgsLegendLayerFileGroup::accept(const QgsLegendItem*
if(li) if(li)
{ {
LEGEND_ITEM_TYPE type = li->type(); 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) 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) void QgsLegendSymbologyGroup::updateLayerSymbologySettings(const QgsMapLayer* thelayer)
{ {
#if 0
//find the legend layer group node //find the legend layer group node
QTreeWidgetItem* parent = this->parent(); QgsLegendItem* parent = dynamic_cast<QgsLegendItem*>(this->parent());
if(!parent) if(!parent)
{ {
return; return;
} }
QTreeWidgetItem* sibling = 0; QgsLegendItem* sibling = 0;
QgsLegendLayerFileGroup* group = 0; QgsLegendLayerFileGroup* group = 0;
for(sibling = parent->firstChild(); sibling != 0; sibling = sibling->nextSibling()) for(sibling = parent->firstChild(); sibling != 0; sibling = sibling->nextSibling())
{ {
@ -108,5 +107,4 @@ void QgsLegendSymbologyGroup::updateLayerSymbologySettings(const QgsMapLayer* th
} }
} }
} }
#endif
} }