From 3d259ba65b0d9c9a7a13a24c521c398f82781203 Mon Sep 17 00:00:00 2001 From: stevehalasz Date: Wed, 4 Feb 2004 19:40:47 +0000 Subject: [PATCH] disable toolbar buttons when not appropriate for current layer type git-svn-id: http://svn.osgeo.org/qgis/trunk@696 c8812cc2-4d05-0410-92ff-de0c093fc19c --- TODO | 8 ++++---- src/qgisapp.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/qgisapp.h | 2 ++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index feb51a85bb5..9fc073fd7b0 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -TODO,v 1.12 2004/01/28 04:53:14 gsherman Exp +TODO,v 1.13 2004/02/04 19:40:47 stevehalasz Exp TODO List for getting to version 0.1 (in no order of importance) 1. Fix QgsProjectIo so that qgis projects can be saved and loaded. Major areas needing attention are customized raster settings and symbology for vector @@ -9,9 +9,9 @@ TODO List for getting to version 0.1 (in no order of importance) name and a suitable pixmap. Will improve later. 4. [DONE (TS/GS)] Implement context menus for raster and vector layers. Will add advanced functions later. - 5. Toolbar buttons related to layer functions need to be disabled when not - appropriate (eg. table and select buttons when a raster is selected in - the legend) + 5. [DONE (SH)] Toolbar buttons related to layer functions need to be disabled + when not appropriate (eg. table and select buttons when a raster is + selected in the legend) 6. SPIT integration needs to be completed. The libpq++ dependency must be removed and the current open bugs (sf.net) need to be resolved. 7. Adjust the open dialog for "shapefiles" to allow other formats supported diff --git a/src/qgisapp.cpp b/src/qgisapp.cpp index 71cecdb229a..739cbcfc7b6 100644 --- a/src/qgisapp.cpp +++ b/src/qgisapp.cpp @@ -250,6 +250,8 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare connect(legendView, SIGNAL(rightButtonPressed(QListViewItem *, const QPoint &, int)), this, SLOT(rightClickLegendMenu(QListViewItem *, const QPoint &, int))); connect(legendView, SIGNAL(zOrderChanged(QgsLegendView *)), mapCanvas, SLOT(setZOrderFromLegend(QgsLegendView *))); + connect(legendView, SIGNAL(currentChanged(QListViewItem *)), + this, SLOT(clickLegendMenu(QListViewItem *))); // create the layer popup menu /* popMenu = new QPopupMenu(); @@ -1030,6 +1032,42 @@ void QgisApp::rightClickLegendMenu(QListViewItem * lvi, const QPoint & pt, int) } } +void QgisApp::clickLegendMenu(QListViewItem * lvi) +{ + if (lvi) { + // disable/enable toolbar buttons as appropriate based on selected + // layer type + QgsMapLayer *lyr = ((QgsLegendItem *) lvi)->layer(); + if (lyr->type() == QgsMapLayer::RASTER) { + actionIdentify->setEnabled( FALSE ); + actionSelect->setEnabled( FALSE ); + actionOpenTable->setEnabled( FALSE ); + // if one of these map tools is selected, set cursor to default + if (mapTool == QGis::Identify || mapTool == QGis::Select || mapTool == QGis::Table) { + delete mapCursor; + mapCursor = new QCursor(); + mapCanvas->setCursor(*mapCursor); + } + } else { + actionIdentify->setEnabled( TRUE ); + actionSelect->setEnabled( TRUE ); + actionOpenTable->setEnabled( TRUE ); + // if one of these map tools is selected, make sure appropriate cursor gets set + switch (mapTool) { + case QGis::Identify: + identify(); + break; + case QGis::Select: + select(); + break; + case QGis::Table: + attributeTable(); + break; + } + } + } +} + QgisIface * QgisApp::getInterface(){ return qgisInterface; } diff --git a/src/qgisapp.h b/src/qgisapp.h index 3786b236125..46fba21249f 100644 --- a/src/qgisapp.h +++ b/src/qgisapp.h @@ -105,6 +105,8 @@ class QgisApp:public QgisAppBase void layerProperties(); //! Show the right-click menu for the legend void rightClickLegendMenu(QListViewItem *, const QPoint &, int); + //! Disable/enable toolbar buttons as appropriate for selected layer + void clickLegendMenu(QListViewItem *); //! Remove a layer from the map and legend void removeLayer(); //! zoom to extent of layer