mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Fix crash when qgis loads shapefile with empty .dbf
Add transparency slider to raster popup menu. Adding 'show in overview' mpopup menu option to raster (incomplete). git-svn-id: http://svn.osgeo.org/qgis/trunk@1539 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
a7d36ce73d
commit
507f1b2132
@ -73,6 +73,8 @@ email : tim at linfiniti.com
|
||||
#include <stdio.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qregexp.h>
|
||||
#include <qslider.h>
|
||||
#include <qlabel.h>
|
||||
|
||||
#include "qgsrasterlayer.h"
|
||||
#include "qgsrect.h"
|
||||
@ -317,12 +319,19 @@ void QgsRasterLayer::setDrawingStyle(QString theDrawingStyleQString)
|
||||
|
||||
//
|
||||
//should be between 0 and 255
|
||||
void QgsRasterLayer::setTransparency(unsigned int theInt)
|
||||
void QgsRasterLayer::setTransparency(int theInt)
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Set transparency called with : " << theInt << std::endl;
|
||||
#endif
|
||||
if (theInt > 255)
|
||||
{
|
||||
transparencyLevelInt = 255;
|
||||
}
|
||||
else if (theInt < 0)
|
||||
{
|
||||
transparencyLevelInt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
transparencyLevelInt = theInt;
|
||||
@ -2170,12 +2179,45 @@ QPopupMenu *QgsRasterLayer::contextMenu()
|
||||
void QgsRasterLayer::initContextMenu(QgisApp * theApp)
|
||||
{
|
||||
popMenu = new QPopupMenu();
|
||||
popMenu->setCheckable ( true );
|
||||
//create a heading label for the menu:
|
||||
QLabel *myPopupLabel = new QLabel( popMenu );
|
||||
myPopupLabel->setFrameStyle( QFrame::Panel | QFrame::Raised );
|
||||
myPopupLabel->setText( tr("<center><b>Raster Layer</b></center>") );
|
||||
popMenu->insertItem(myPopupLabel,0);
|
||||
//
|
||||
popMenu->insertItem(tr("&Zoom to extent of selected layer"), theApp, SLOT(zoomToLayerExtent()));
|
||||
popMenu->insertItem(tr("&Properties"), theApp, SLOT(layerProperties()));
|
||||
//show in overview slot is implemented in maplayer superclass!
|
||||
popMenu->insertItem(tr("Show In &Overview"), theApp, SLOT(showInOverview(bool)),1);//1 is a user assigned id for the menu item
|
||||
popMenu->setItemChecked(1,true);
|
||||
popMenu->insertSeparator();
|
||||
//If a widget is not focus-enabled (see QWidget::isFocusEnabled()), the menu treats it as a separator;
|
||||
//this means that the item is not selectable and will never get focus. In this way you can, for example,
|
||||
//simply insert a QLabel if you need a popup menu with a title.
|
||||
QLabel * myTransparencyLabel = new QLabel( popMenu );
|
||||
myTransparencyLabel->setFrameStyle( QFrame::Panel | QFrame::Raised );
|
||||
myTransparencyLabel->setText( tr("<center><b>Transparency</b></center>") );
|
||||
popMenu->insertItem(myTransparencyLabel,2);
|
||||
popMenu->setItemEnabled(2,false);
|
||||
// QSlider ( int minValue, int maxValue, int pageStep, int value, Orientation orientation, QWidget * parent, const char * name = 0 )
|
||||
QSlider * myTransparencySlider = new QSlider(0,255,5,255-transparencyLevelInt,QSlider::Horizontal,popMenu);
|
||||
myTransparencySlider->setTickmarks(QSlider::Both);
|
||||
myTransparencySlider->setTickInterval(25);
|
||||
myTransparencySlider->setTracking(false); //stop slider emmitting a signal until mouse released
|
||||
connect(myTransparencySlider, SIGNAL(valueChanged(int)), this, SLOT(popupTransparencySliderMoved(int)));
|
||||
popMenu->insertItem(myTransparencySlider,3);
|
||||
|
||||
popMenu->insertSeparator();
|
||||
popMenu->insertItem(tr("&Remove"), theApp, SLOT(removeLayer()));
|
||||
}
|
||||
|
||||
void QgsRasterLayer::popupTransparencySliderMoved(int theInt)
|
||||
{
|
||||
setTransparency(255-theInt);
|
||||
triggerRepaint();
|
||||
}
|
||||
|
||||
QString QgsRasterLayer::getMetadata()
|
||||
{
|
||||
QString myMetadataQString = "<html><body>";
|
||||
|
@ -408,7 +408,7 @@ public:
|
||||
/** \brief accessor for transparency level. */
|
||||
unsigned int getTransparency();
|
||||
/** \brief Mutator for transparency level. Should be between 0 and 255 */
|
||||
void setTransparency(unsigned int); //
|
||||
void setTransparency(int); //
|
||||
/** \brief Call any inline image manipulation filters */
|
||||
void filterLayer(QImage * theQImage);
|
||||
/** \brief Accessor for red band name (allows alternate mappings e.g. map blue as red colour). */
|
||||
@ -732,6 +732,9 @@ public:
|
||||
|
||||
|
||||
public slots:
|
||||
/** \brief Slot called when the popup menu transparency slider has been moved.*/
|
||||
void popupTransparencySliderMoved(int);
|
||||
|
||||
/** \brief Create gdal pyramid overviews for this layer.
|
||||
* This will speed up performance at the expense of hard drive space.
|
||||
* Also, write access to the file is required. If no paramter is passed in
|
||||
|
@ -33,6 +33,8 @@ email : sherman at mrcc.com
|
||||
#include <qstring.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qpopupmenu.h>
|
||||
#include <qlabel.h>
|
||||
|
||||
#include "qgisapp.h"
|
||||
#include "qgsrect.h"
|
||||
#include "qgspoint.h"
|
||||
@ -234,8 +236,8 @@ void QgsVectorLayer::setDisplayField()
|
||||
// dialog. We look for fields containing "name" first and second for
|
||||
// fields containing "id". If neither are found, the first field
|
||||
// is used as the node.
|
||||
QString idxName;
|
||||
QString idxId;
|
||||
QString idxName="";
|
||||
QString idxId="";
|
||||
|
||||
std::vector < QgsField > fields = dataProvider->fields();
|
||||
int j = 0;
|
||||
@ -263,6 +265,8 @@ void QgsVectorLayer::setDisplayField()
|
||||
}
|
||||
}
|
||||
|
||||
//if there were no fields in the dbf just return - otherwise qgis segfaults!
|
||||
if (j==0) return;
|
||||
|
||||
if (idxName.length() > 0)
|
||||
{
|
||||
@ -899,6 +903,10 @@ QObject:connect(tabledisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDispl
|
||||
void QgsVectorLayer::initContextMenu(QgisApp * app)
|
||||
{
|
||||
popMenu = new QPopupMenu();
|
||||
QLabel *myPopupLabel = new QLabel( popMenu );
|
||||
myPopupLabel->setFrameStyle( QFrame::Panel | QFrame::Raised );
|
||||
myPopupLabel->setText( tr("<center><b>Vector Layer</b></center>") );
|
||||
popMenu->insertItem(myPopupLabel,0);
|
||||
popMenu->insertItem(tr("&Zoom to extent of selected layer"), app, SLOT(zoomToLayerExtent()));
|
||||
popMenu->insertItem(tr("&Open attribute table"), app, SLOT(attributeTable()));
|
||||
popMenu->insertSeparator();
|
||||
|
Loading…
x
Reference in New Issue
Block a user