changes to support identify and attribute display functions

git-svn-id: http://svn.osgeo.org/qgis/trunk@147 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2002-11-24 00:00:43 +00:00
parent c13d055a8c
commit 2c85d6985a
19 changed files with 518 additions and 242 deletions

View File

@ -1,6 +1,6 @@
############################################################################# #############################################################################
# Makefile for building: qgis # Makefile for building: qgis
# Generated by qmake (1.03a) on: Fri Oct 25 15:00:41 2002 # Generated by qmake (1.03a) on: Sat Nov 23 15:07:42 2002
# Project: src.pro # Project: src.pro
# Template: app # Template: app
# Command: $(QMAKE) src.pro # Command: $(QMAKE) src.pro
@ -63,7 +63,9 @@ HEADERS = qgsdbsourceselectbase.ui.h \
qgslegend.h \ qgslegend.h \
qgslegenditem.h \ qgslegenditem.h \
qgslayerproperties.h \ qgslayerproperties.h \
qgsidentifyresults.h qgsidentifyresults.h \
qgsattributetable.h \
qgsattributetabledisplay.h
SOURCES = main.cpp \ SOURCES = main.cpp \
qgisapp.cpp \ qgisapp.cpp \
qgsdatabaselayer.cpp \ qgsdatabaselayer.cpp \
@ -84,7 +86,9 @@ SOURCES = main.cpp \
qgslinesymbol.cpp \ qgslinesymbol.cpp \
qgspolygonsymbol.cpp \ qgspolygonsymbol.cpp \
qgslayerproperties.cpp \ qgslayerproperties.cpp \
qgsidentifyresults.cpp qgsidentifyresults.cpp \
qgsattributetable.cpp \
qgsattributetabledisplay.cpp
OBJECTS = main.o \ OBJECTS = main.o \
qgisapp.o \ qgisapp.o \
qgsdatabaselayer.o \ qgsdatabaselayer.o \
@ -106,34 +110,40 @@ OBJECTS = main.o \
qgspolygonsymbol.o \ qgspolygonsymbol.o \
qgslayerproperties.o \ qgslayerproperties.o \
qgsidentifyresults.o \ qgsidentifyresults.o \
qgsattributetable.o \
qgsattributetabledisplay.o \
qgsdbsourceselectbase.o \ qgsdbsourceselectbase.o \
qgisappbase.o \ qgisappbase.o \
qgsnewconnectionbase.o \ qgsnewconnectionbase.o \
qgslegenditembase.o \ qgslegenditembase.o \
qgsabout.o \ qgsabout.o \
qgslayerpropertiesbase.o \ qgslayerpropertiesbase.o \
qgsidentifyresultsbase.o qgsidentifyresultsbase.o \
qgsattributetablebase.o
FORMS = qgsdbsourceselectbase.ui \ FORMS = qgsdbsourceselectbase.ui \
qgisappbase.ui \ qgisappbase.ui \
qgsnewconnectionbase.ui \ qgsnewconnectionbase.ui \
qgslegenditembase.ui \ qgslegenditembase.ui \
qgsabout.ui \ qgsabout.ui \
qgslayerpropertiesbase.ui \ qgslayerpropertiesbase.ui \
qgsidentifyresultsbase.ui qgsidentifyresultsbase.ui \
qgsattributetablebase.ui
UICDECLS = qgsdbsourceselectbase.h \ UICDECLS = qgsdbsourceselectbase.h \
qgisappbase.h \ qgisappbase.h \
qgsnewconnectionbase.h \ qgsnewconnectionbase.h \
qgslegenditembase.h \ qgslegenditembase.h \
qgsabout.h \ qgsabout.h \
qgslayerpropertiesbase.h \ qgslayerpropertiesbase.h \
qgsidentifyresultsbase.h qgsidentifyresultsbase.h \
qgsattributetablebase.h
UICIMPLS = qgsdbsourceselectbase.cpp \ UICIMPLS = qgsdbsourceselectbase.cpp \
qgisappbase.cpp \ qgisappbase.cpp \
qgsnewconnectionbase.cpp \ qgsnewconnectionbase.cpp \
qgslegenditembase.cpp \ qgslegenditembase.cpp \
qgsabout.cpp \ qgsabout.cpp \
qgslayerpropertiesbase.cpp \ qgslayerpropertiesbase.cpp \
qgsidentifyresultsbase.cpp qgsidentifyresultsbase.cpp \
qgsattributetablebase.cpp
SRCMOC = moc_qgisapp.cpp \ SRCMOC = moc_qgisapp.cpp \
moc_qgsdatabaselayer.cpp \ moc_qgsdatabaselayer.cpp \
moc_qgsmapcanvas.cpp \ moc_qgsmapcanvas.cpp \
@ -141,13 +151,15 @@ SRCMOC = moc_qgisapp.cpp \
moc_qgsrasterlayer.cpp \ moc_qgsrasterlayer.cpp \
moc_qgsshapefilelayer.cpp \ moc_qgsshapefilelayer.cpp \
moc_qgslegend.cpp \ moc_qgslegend.cpp \
moc_qgsattributetable.cpp \
moc_qgsdbsourceselectbase.cpp \ moc_qgsdbsourceselectbase.cpp \
moc_qgisappbase.cpp \ moc_qgisappbase.cpp \
moc_qgsnewconnectionbase.cpp \ moc_qgsnewconnectionbase.cpp \
moc_qgslegenditembase.cpp \ moc_qgslegenditembase.cpp \
moc_qgsabout.cpp \ moc_qgsabout.cpp \
moc_qgslayerpropertiesbase.cpp \ moc_qgslayerpropertiesbase.cpp \
moc_qgsidentifyresultsbase.cpp moc_qgsidentifyresultsbase.cpp \
moc_qgsattributetablebase.cpp
OBJMOC = moc_qgisapp.o \ OBJMOC = moc_qgisapp.o \
moc_qgsdatabaselayer.o \ moc_qgsdatabaselayer.o \
moc_qgsmapcanvas.o \ moc_qgsmapcanvas.o \
@ -155,13 +167,15 @@ OBJMOC = moc_qgisapp.o \
moc_qgsrasterlayer.o \ moc_qgsrasterlayer.o \
moc_qgsshapefilelayer.o \ moc_qgsshapefilelayer.o \
moc_qgslegend.o \ moc_qgslegend.o \
moc_qgsattributetable.o \
moc_qgsdbsourceselectbase.o \ moc_qgsdbsourceselectbase.o \
moc_qgisappbase.o \ moc_qgisappbase.o \
moc_qgsnewconnectionbase.o \ moc_qgsnewconnectionbase.o \
moc_qgslegenditembase.o \ moc_qgslegenditembase.o \
moc_qgsabout.o \ moc_qgsabout.o \
moc_qgslayerpropertiesbase.o \ moc_qgslayerpropertiesbase.o \
moc_qgsidentifyresultsbase.o moc_qgsidentifyresultsbase.o \
moc_qgsattributetablebase.o
DIST = src.pro DIST = src.pro
QMAKE_TARGET = qgis QMAKE_TARGET = qgis
DESTDIR = DESTDIR =
@ -260,11 +274,13 @@ qgsdatabaselayer.o: qgsdatabaselayer.cpp qgis.h \
qgspoint.h \ qgspoint.h \
qgsdatabaselayer.h \ qgsdatabaselayer.h \
qgsidentifyresults.h \ qgsidentifyresults.h \
qgsattributetabledisplay.h \
qgsmaplayer.h \ qgsmaplayer.h \
qgsdatasource.h \ qgsdatasource.h \
qgscoordinatetransform.h \ qgscoordinatetransform.h \
qgssymbol.h \ qgssymbol.h \
qgsidentifyresultsbase.h qgsidentifyresultsbase.h \
qgsattributetablebase.h
qgsdatasource.o: qgsdatasource.cpp qgsdatasource.h qgsdatasource.o: qgsdatasource.cpp qgsdatasource.h
@ -301,10 +317,12 @@ qgsshapefilelayer.o: qgsshapefilelayer.cpp qgsrect.h \
qgspoint.h \ qgspoint.h \
qgscoordinatetransform.h \ qgscoordinatetransform.h \
qgsshapefilelayer.h \ qgsshapefilelayer.h \
qgsidentifyresults.h \
qgsmaplayer.h \ qgsmaplayer.h \
qgsdatasource.h \ qgsdatasource.h \
qgis.h \ qgis.h \
qgssymbol.h qgssymbol.h \
qgsidentifyresultsbase.h
qgsdbsourceselect.o: qgsdbsourceselect.cpp xpm/point_layer.xpm \ qgsdbsourceselect.o: qgsdbsourceselect.cpp xpm/point_layer.xpm \
xpm/line_layer.xpm \ xpm/line_layer.xpm \
@ -367,6 +385,11 @@ qgslayerproperties.o: qgslayerproperties.cpp qgsmaplayer.h \
qgsidentifyresults.o: qgsidentifyresults.cpp qgsidentifyresults.h \ qgsidentifyresults.o: qgsidentifyresults.cpp qgsidentifyresults.h \
qgsidentifyresultsbase.h qgsidentifyresultsbase.h
qgsattributetable.o: qgsattributetable.cpp qgsattributetable.h
qgsattributetabledisplay.o: qgsattributetabledisplay.cpp qgsattributetabledisplay.h \
qgsattributetablebase.h
qgsdbsourceselectbase.h: qgsdbsourceselectbase.ui qgsdbsourceselectbase.h: qgsdbsourceselectbase.ui
$(UIC) qgsdbsourceselectbase.ui -o qgsdbsourceselectbase.h $(UIC) qgsdbsourceselectbase.ui -o qgsdbsourceselectbase.h
@ -409,11 +432,16 @@ qgsidentifyresultsbase.h: qgsidentifyresultsbase.ui
qgsidentifyresultsbase.cpp: qgsidentifyresultsbase.h qgsidentifyresultsbase.ui qgsidentifyresultsbase.cpp: qgsidentifyresultsbase.h qgsidentifyresultsbase.ui
$(UIC) qgsidentifyresultsbase.ui -i qgsidentifyresultsbase.h -o qgsidentifyresultsbase.cpp $(UIC) qgsidentifyresultsbase.ui -i qgsidentifyresultsbase.h -o qgsidentifyresultsbase.cpp
qgsattributetablebase.h: qgsattributetablebase.ui
$(UIC) qgsattributetablebase.ui -o qgsattributetablebase.h
qgsattributetablebase.cpp: qgsattributetablebase.h qgsattributetablebase.ui
$(UIC) qgsattributetablebase.ui -i qgsattributetablebase.h -o qgsattributetablebase.cpp
qgsdbsourceselectbase.o: qgsdbsourceselectbase.cpp qgsdbsourceselectbase.ui.h \ qgsdbsourceselectbase.o: qgsdbsourceselectbase.cpp qgsdbsourceselectbase.ui.h \
qgsdbsourceselectbase.h qgsdbsourceselectbase.h
qgisappbase.o: qgisappbase.cpp qgisappbase.ui.h \ qgisappbase.o: qgisappbase.cpp qgisappbase.h
qgisappbase.h
qgsnewconnectionbase.o: qgsnewconnectionbase.cpp qgsnewconnectionbase.h qgsnewconnectionbase.o: qgsnewconnectionbase.cpp qgsnewconnectionbase.h
@ -426,6 +454,8 @@ qgslayerpropertiesbase.o: qgslayerpropertiesbase.cpp qgslayerpropertiesbase.h
qgsidentifyresultsbase.o: qgsidentifyresultsbase.cpp qgsidentifyresultsbase.h qgsidentifyresultsbase.o: qgsidentifyresultsbase.cpp qgsidentifyresultsbase.h
qgsattributetablebase.o: qgsattributetablebase.cpp qgsattributetablebase.h
moc_qgisapp.o: moc_qgisapp.cpp qgisapp.h qgisappbase.h moc_qgisapp.o: moc_qgisapp.cpp qgisapp.h qgisappbase.h
moc_qgsdatabaselayer.o: moc_qgsdatabaselayer.cpp qgsdatabaselayer.h qgsmaplayer.h \ moc_qgsdatabaselayer.o: moc_qgsdatabaselayer.cpp qgsdatabaselayer.h qgsmaplayer.h \
@ -460,6 +490,8 @@ moc_qgsshapefilelayer.o: moc_qgsshapefilelayer.cpp qgsshapefilelayer.h qgsmaplay
moc_qgslegend.o: moc_qgslegend.cpp qgslegend.h moc_qgslegend.o: moc_qgslegend.cpp qgslegend.h
moc_qgsattributetable.o: moc_qgsattributetable.cpp qgsattributetable.h
moc_qgsdbsourceselectbase.o: moc_qgsdbsourceselectbase.cpp qgsdbsourceselectbase.h moc_qgsdbsourceselectbase.o: moc_qgsdbsourceselectbase.cpp qgsdbsourceselectbase.h
moc_qgisappbase.o: moc_qgisappbase.cpp qgisappbase.h moc_qgisappbase.o: moc_qgisappbase.cpp qgisappbase.h
@ -474,6 +506,8 @@ moc_qgslayerpropertiesbase.o: moc_qgslayerpropertiesbase.cpp qgslayerpropertiesb
moc_qgsidentifyresultsbase.o: moc_qgsidentifyresultsbase.cpp qgsidentifyresultsbase.h moc_qgsidentifyresultsbase.o: moc_qgsidentifyresultsbase.cpp qgsidentifyresultsbase.h
moc_qgsattributetablebase.o: moc_qgsattributetablebase.cpp qgsattributetablebase.h
moc_qgisapp.cpp: $(MOC) qgisapp.h moc_qgisapp.cpp: $(MOC) qgisapp.h
$(MOC) qgisapp.h -o moc_qgisapp.cpp $(MOC) qgisapp.h -o moc_qgisapp.cpp
@ -495,6 +529,9 @@ moc_qgsshapefilelayer.cpp: $(MOC) qgsshapefilelayer.h
moc_qgslegend.cpp: $(MOC) qgslegend.h moc_qgslegend.cpp: $(MOC) qgslegend.h
$(MOC) qgslegend.h -o moc_qgslegend.cpp $(MOC) qgslegend.h -o moc_qgslegend.cpp
moc_qgsattributetable.cpp: $(MOC) qgsattributetable.h
$(MOC) qgsattributetable.h -o moc_qgsattributetable.cpp
moc_qgsdbsourceselectbase.cpp: $(MOC) qgsdbsourceselectbase.h moc_qgsdbsourceselectbase.cpp: $(MOC) qgsdbsourceselectbase.h
$(MOC) qgsdbsourceselectbase.h -o moc_qgsdbsourceselectbase.cpp $(MOC) qgsdbsourceselectbase.h -o moc_qgsdbsourceselectbase.cpp
@ -516,6 +553,9 @@ moc_qgslayerpropertiesbase.cpp: $(MOC) qgslayerpropertiesbase.h
moc_qgsidentifyresultsbase.cpp: $(MOC) qgsidentifyresultsbase.h moc_qgsidentifyresultsbase.cpp: $(MOC) qgsidentifyresultsbase.h
$(MOC) qgsidentifyresultsbase.h -o moc_qgsidentifyresultsbase.cpp $(MOC) qgsidentifyresultsbase.h -o moc_qgsidentifyresultsbase.cpp
moc_qgsattributetablebase.cpp: $(MOC) qgsattributetablebase.h
$(MOC) qgsattributetablebase.h -o moc_qgsattributetablebase.cpp
####### Install ####### Install
install: all install: all

View File

@ -10,16 +10,20 @@
* *
*/ */
namespace QGis { namespace QGis
enum MapTools { {
enum MapTools
{
ZoomIn, ZoomIn,
ZoomOut, ZoomOut,
Pan, Pan,
Distance, Distance,
Identify Identify,
Table
}; };
//! Used for symbology operations //! Used for symbology operations
enum WKBTYPE{ enum WKBTYPE
{
WKBPoint = 1, WKBPoint = 1,
WKBLineString, WKBLineString,
WKBPolygon, WKBPolygon,

View File

@ -36,7 +36,7 @@ User Interface=*.kdevdlg,*.ui,*.rc,*.dlg
groups=Headers,Sources,User Interface,Others groups=Headers,Sources,User Interface,Others
[Makefile.am] [Makefile.am]
files=main.cpp,qgisapp.cpp,qgscoordinatetransform.cpp,qgsdatabaselayer.cpp,qgsdatasource.cpp,qgsdbsourceselect.cpp,qgsmapcanvas.cpp,qgsmaplayer.cpp,qgsnewconnection.cpp,qgspoint.cpp,qgsrasterlayer.cpp,qgsrect.cpp,qgisapp.h,qgscoordinatetransform.h,qgsdatabaselayer.h,qgsdatasource.h,qgsdbsourceselect.h,qgslinesymbol.h,qgsmapcanvas.h,qgsmaplayer.h,qgsmarkersymbol.h,qgsnewconnection.h,qgspoint.h,qgspolygonsymbol.h,qgsrasterlayer.h,qgsrect.h,qgsshapefilelayer.h,qgisappbase.ui,qgsdbsourceselectbase.ui,qgsnewconnectionbase.ui,qgscustomsymbol.cpp,qgscustomsymbol.h,qgslegend.h,qgslegend.cpp,qgslegenditem.cpp,qgslegenditem.h,qgssymbol.h,qgstable.h,qgsshapefilelayer.cpp,qgslegenditembase.h,qgsabout.ui,qgsabout.ui.h,QgsSymbol.cpp,qgsmarkersymbol.cpp,qgslinesymbol.cpp,qgspolygonsymbol.cpp,qgslayerproperties.cpp,qgslayerproperties.h,qgis.h,qgsidentifyresults.cpp,qgsidentifyresults.h files=main.cpp,qgisapp.cpp,qgscoordinatetransform.cpp,qgsdatabaselayer.cpp,qgsdatasource.cpp,qgsdbsourceselect.cpp,qgsmapcanvas.cpp,qgsmaplayer.cpp,qgsnewconnection.cpp,qgspoint.cpp,qgsrasterlayer.cpp,qgsrect.cpp,qgisapp.h,qgscoordinatetransform.h,qgsdatabaselayer.h,qgsdatasource.h,qgsdbsourceselect.h,qgslinesymbol.h,qgsmapcanvas.h,qgsmaplayer.h,qgsmarkersymbol.h,qgsnewconnection.h,qgspoint.h,qgspolygonsymbol.h,qgsrasterlayer.h,qgsrect.h,qgsshapefilelayer.h,qgisappbase.ui,qgsdbsourceselectbase.ui,qgsnewconnectionbase.ui,qgscustomsymbol.cpp,qgscustomsymbol.h,qgslegend.h,qgslegend.cpp,qgslegenditem.cpp,qgslegenditem.h,qgssymbol.h,qgstable.h,qgsshapefilelayer.cpp,qgslegenditembase.h,qgsabout.ui,qgsabout.ui.h,QgsSymbol.cpp,qgsmarkersymbol.cpp,qgslinesymbol.cpp,qgspolygonsymbol.cpp,qgslayerproperties.cpp,qgslayerproperties.h,qgis.h,qgsidentifyresults.cpp,qgsidentifyresults.h,qgsattributetable.cpp,qgsattributetable.h
sharedlib_LDFLAGS=-version-info 0:0:0 sharedlib_LDFLAGS=-version-info 0:0:0
sharedlib_rootname=src sharedlib_rootname=src
sub_dirs= sub_dirs=
@ -104,6 +104,18 @@ install=false
install_location= install_location=
type=HEADER type=HEADER
[qgsattributetable.cpp]
dist=true
install=false
install_location=
type=SOURCE
[qgsattributetable.h]
dist=true
install=false
install_location=
type=HEADER
[qgscoordinatetransform.cpp] [qgscoordinatetransform.cpp]
dist=true dist=true
install=false install=false

View File

@ -176,7 +176,8 @@ void QgisApp::about()
watsNew += qgisVersion; watsNew += qgisVersion;
watsNew += "\n*Improved handling/management of PostGIS connections\n" watsNew += "\n*Improved handling/management of PostGIS connections\n"
"*Password prompt if the password is not stored with a connection\n" "*Password prompt if the password is not stored with a connection\n"
"*Windows size and postion and toolbar docking state is saved/restored\n"; "*Windows size and position and toolbar docking state is saved/restored\n"
"*Identify function for layers\n" "*Duplicate layers (layers with same name) are now handled properly\n";
abt->setWhatsNew(watsNew); abt->setWhatsNew(watsNew);
abt->exec(); abt->exec();
@ -361,6 +362,18 @@ void QgisApp::identify()
mapCanvas->setCursor(*mapCursor); mapCanvas->setCursor(*mapCursor);
} }
void QgisApp::attributeTable()
{
QListViewItem *li = legendView->currentItem();
QgsMapLayer *lyr = ((QgsLegendItem *) li)->layer();
if (lyr) {
lyr->table();
} else {
QMessageBox::information(this, "No Layer Selected", "To open an attribute table, you must select a layer in the legend");
}
}
//void QgisApp::readWKB (const char *connInfo, QStringList tables) //void QgisApp::readWKB (const char *connInfo, QStringList tables)
//{ //{
// PgCursor pgc (connInfo, "testcursor"); // PgCursor pgc (connInfo, "testcursor");
@ -548,7 +561,8 @@ void QgisApp::removeLayer()
} }
void QgisApp::zoomToLayerExtent(){ void QgisApp::zoomToLayerExtent()
{
// get the selected item // get the selected item
QListViewItem *li = legendView->currentItem(); QListViewItem *li = legendView->currentItem();
@ -598,7 +612,8 @@ void QgisApp::testPluginFunctions()
} }
} }
} else { } else {
QMessageBox::warning(this,"Unable to Load Plugin","QGis was unable to load the plugin from: ../plugins/libqgisplugin.so.1.0.0"); QMessageBox::warning(this, "Unable to Load Plugin",
"QGis was unable to load the plugin from: ../plugins/libqgisplugin.so.1.0.0");
std::cout << "Unable to load library" << std::endl; std::cout << "Unable to load library" << std::endl;
} }
} }
@ -644,4 +659,3 @@ void QgisApp::restoreWindowState()
int y = settings.readNumEntry("/qgis/Geometry/y", (dh - 400) / 2); int y = settings.readNumEntry("/qgis/Geometry/y", (dh - 400) / 2);
setGeometry(x, y, w, h); setGeometry(x, y, w, h);
} }

View File

@ -35,9 +35,9 @@ class QgsMapCanvas;
/*! \class QgisApp /*! \class QgisApp
* \brief Main window for the Qgis application * \brief Main window for the Qgis application
*/ */
class QgisApp : public QgisAppBase { class QgisApp:public QgisAppBase
Q_OBJECT {
public: Q_OBJECT public:
//! Constructor //! Constructor
QgisApp(QWidget * parent = 0, const char *name = 0, WFlags fl = WType_TopLevel); QgisApp(QWidget * parent = 0, const char *name = 0, WFlags fl = WType_TopLevel);
@ -59,7 +59,10 @@ public:
void zoomPrevious(); void zoomPrevious();
//! Set map tool to pan //! Set map tool to pan
void pan(); void pan();
//! Identify feature(s) on the currently selected layer
void identify(); void identify();
//! show the attribute table for the currently selected layer
void attributeTable();
//! Read Well Known Binary stream from PostGIS //! Read Well Known Binary stream from PostGIS
//void readWKB(const char *, QStringList tables); //void readWKB(const char *, QStringList tables);
//! Draw a point on the map canvas //! Draw a point on the map canvas

View File

@ -456,26 +456,30 @@
<receiver>QgisAppBase</receiver> <receiver>QgisAppBase</receiver>
<slot>testPluginFunctions()</slot> <slot>testPluginFunctions()</slot>
</connection> </connection>
<connection>
<sender>actionOpenTable</sender>
<signal>activated()</signal>
<receiver>QgisAppBase</receiver>
<slot>attributeTable()</slot>
</connection>
</connections> </connections>
<includes>
<include location="local" impldecl="in implementation">qgisappbase.ui.h</include>
</includes>
<slots> <slots>
<slot>about()</slot>
<slot>addDatabaseLayer()</slot>
<slot>addLayer()</slot>
<slot>drawLayers()</slot>
<slot>fileExit()</slot> <slot>fileExit()</slot>
<slot>fileOpen()</slot> <slot>fileOpen()</slot>
<slot>addDatabaseLayer()</slot> <slot>identify()</slot>
<slot>init()</slot>
<slot>attributeTable()</slot>
<slot>pan()</slot>
<slot>testButton()</slot>
<slot>testPluginFunctions()</slot>
<slot>zoomFull()</slot>
<slot>zoomIn()</slot> <slot>zoomIn()</slot>
<slot>zoomOut()</slot> <slot>zoomOut()</slot>
<slot>init()</slot>
<slot>drawLayers()</slot>
<slot>zoomFull()</slot>
<slot>pan()</slot>
<slot>about()</slot>
<slot>testButton()</slot>
<slot>addLayer()</slot>
<slot>identify()</slot>
<slot>zoomPrevious()</slot> <slot>zoomPrevious()</slot>
<slot>testPluginFunctions()</slot>
</slots> </slots>
<layoutdefaults spacing="6" margin="11"/> <layoutdefaults spacing="6" margin="11"/>
</UI> </UI>

View File

@ -85,6 +85,11 @@ void QgisAppBase::identify()
} }
void QgisAppBase::attributeTable()
{
}
void QgisAppBase::zoomPrevious() void QgisAppBase::zoomPrevious()
{ {

View File

@ -15,11 +15,14 @@
* * * *
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <qapplication.h>
#include <qcursor.h>
#include <qstring.h> #include <qstring.h>
#include <qpainter.h> #include <qpainter.h>
#include <qpen.h> #include <qpen.h>
#include <qpointarray.h> #include <qpointarray.h>
#include <qbrush.h> #include <qbrush.h>
#include "qgis.h" #include "qgis.h"
#include "qgsrect.h" #include "qgsrect.h"
#include "qgspoint.h" #include "qgspoint.h"
@ -27,9 +30,11 @@
#include <qmessagebox.h> #include <qmessagebox.h>
#include "qgsdatabaselayer.h" #include "qgsdatabaselayer.h"
#include "qgsidentifyresults.h" #include "qgsidentifyresults.h"
#include "qgsattributetable.h"
#include "qgsattributetabledisplay.h"
QgsDatabaseLayer::QgsDatabaseLayer(const char *conninfo, QString table): QgsDatabaseLayer::QgsDatabaseLayer(const char *conninfo, QString table):QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo),
QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table) tableName(table)
{ {
// create the database layer and get the needed information // create the database layer and get the needed information
// about it from the database // about it from the database
@ -450,13 +455,59 @@ void QgsDatabaseLayer::identify(QgsRect * r)
val = pgs.GetValue(0, i); val = pgs.GetValue(0, i);
ir->addAttribute(fld, val); ir->addAttribute(fld, val);
} }
ir->setTitle(name());
ir->show(); ir->show();
} else { } else {
QMessageBox::information(0, "No features found", "No features were found in the active layer at the point you clicked"); QMessageBox::information(0, "No features found", "No features were found in the active layer at the point you clicked");
} }
int foo = 0;
} }
void QgsDatabaseLayer::table()
{
// display the attribute table
QString sql = "select * from " + tableName;
qWarning(sql);
// select the features
PgCursor pgs(dataSource, "attributeCursor");
pgs.Declare((const char *) sql, false);
int res = pgs.Fetch();
QString msg;
QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl;
// create the results window
if (pgs.Tuples() > 0) {
QApplication::setOverrideCursor(Qt::WaitCursor);
QgsAttributeTableDisplay *at = new QgsAttributeTableDisplay();
at->table()->setNumRows(pgs.Tuples());
at->table()->setNumCols(pgs.Fields());
// set the column headers
QHeader *colHeader = at->table()->horizontalHeader();
for (int h = 0; h < pgs.Fields(); h++) {
colHeader->setLabel(h, pgs.FieldName(h));
}
// add the data to the rows
for (int ir = 0; ir < pgs.Tuples(); ir++) {
for (int ic = 0; ic < pgs.Fields(); ic++) {
int fldType = pgs.FieldType(ic);
QString val;
if (fldType == 16604) // geometry -- naughty -- shouldnt code to a value
val = "(geometry column)";
else
val = pgs.GetValue(ir, ic);
at->table()->setText(ir, ic, val);
}
}
at->table()->setSorting(true);
QApplication::restoreOverrideCursor();
at->setTitle("Attribute table - " + name());
at->show();
}
}
int QgsDatabaseLayer::endian() int QgsDatabaseLayer::endian()
{ {
char *chkEndian = new char[4]; char *chkEndian = new char[4];

View File

@ -27,9 +27,9 @@ class QgsRect;
* *
* At present Qgis supports PostGIS "layers" in PostgresQL. * At present Qgis supports PostGIS "layers" in PostgresQL.
*/ */
class QgsDatabaseLayer : public QgsMapLayer { class QgsDatabaseLayer:public QgsMapLayer
Q_OBJECT {
public: Q_OBJECT public:
/*! Constructor /*! Constructor
* @param conninfo Pointer to the connection information required to * @param conninfo Pointer to the connection information required to
* connect to PostgresQL * connect to PostgresQL
@ -39,9 +39,14 @@ Q_OBJECT
QgsDatabaseLayer(const char *conninfo = 0, QString table = QString::null); QgsDatabaseLayer(const char *conninfo = 0, QString table = QString::null);
//! Destructor //! Destructor
~QgsDatabaseLayer(); ~QgsDatabaseLayer();
//! Deprecated draw function
virtual void draw(QPainter *, QgsRect *, int); virtual void draw(QPainter *, QgsRect *, int);
//! Draws the layer using coordinate transformation
virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * cFx); virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * cFx);
//! Identify the feature found within the search rectangle
void identify(QgsRect *); void identify(QgsRect *);
//! Display the attribute table
void table();
private: private:
//! Calculates extent of the layer using SQL and PostGIS functions //! Calculates extent of the layer using SQL and PostGIS functions
QgsRect calculateExtent(); QgsRect calculateExtent();
@ -57,7 +62,8 @@ Q_OBJECT
QString geometryColumn; QString geometryColumn;
//OGIS WKB types //OGIS WKB types
enum ENDIAN{ enum ENDIAN
{
NDR = 1, NDR = 1,
XDR = 0 XDR = 0
}; };

View File

@ -18,11 +18,21 @@
#include <qlistview.h> #include <qlistview.h>
#include "qgsidentifyresults.h" #include "qgsidentifyresults.h"
QgsIdentifyResults::QgsIdentifyResults(){ QgsIdentifyResults::QgsIdentifyResults()
{
} }
QgsIdentifyResults::~QgsIdentifyResults(){
QgsIdentifyResults::~QgsIdentifyResults()
{
} }
/** add an attribute and its value to the list */ /** add an attribute and its value to the list */
void QgsIdentifyResults::addAttribute(QString field, QString value){ void QgsIdentifyResults::addAttribute(QString field, QString value)
{
QListViewItem *lvi = new QListViewItem(lstResults, field, value); QListViewItem *lvi = new QListViewItem(lstResults, field, value);
} }
void QgsIdentifyResults::setTitle(QString title)
{
setCaption("Identify Results - " + title);
}

View File

@ -25,12 +25,14 @@
*@author Gary E.Sherman *@author Gary E.Sherman
*/ */
class QgsIdentifyResults : public QgsIdentifyResultsBase { class QgsIdentifyResults:public QgsIdentifyResultsBase
{
public: public:
QgsIdentifyResults(); QgsIdentifyResults();
~QgsIdentifyResults(); ~QgsIdentifyResults();
/** No descriptions */ /** No descriptions */
void addAttribute(QString field, QString value); void addAttribute(QString field, QString value);
void setTitle(QString title);
}; };
#endif #endif

View File

@ -40,13 +40,28 @@ void QgsLegend::setMapCanvas(QgsMapCanvas * canvas)
map = canvas; map = canvas;
} }
QString QgsLegend::currentLayer(){ QgsMapLayer *QgsLegend::currentLayer()
{
QgsLegendItem *li = (QgsLegendItem *) listView->currentItem();
if (li)
return li->layer();
else
return 0;
}
QString QgsLegend::currentLayerName()
{
QListViewItem *li = listView->currentItem(); QListViewItem *li = listView->currentItem();
if (li) if (li)
return li->text(0); return li->text(0);
else else
return 0; return 0;
} }
void QgsLegend::update() void QgsLegend::update()
{ {
// clear the legend // clear the legend

View File

@ -32,9 +32,9 @@ class QPainter;
*@author Gary E.Sherman *@author Gary E.Sherman
*/ */
class QgsLegend : public QWidget{ class QgsLegend:public QWidget
Q_OBJECT {
public: Q_OBJECT public:
/*! Constructor. /*! Constructor.
* @param lv ListView control containing legend items * @param lv ListView control containing legend items
* @param parent Parent widget * @param parent Parent widget
@ -47,7 +47,9 @@ public:
void setMapCanvas(QgsMapCanvas * canvas); void setMapCanvas(QgsMapCanvas * canvas);
//! Update the legend //! Update the legend
void update(); void update();
QString currentLayer(); QString currentLayerName();
QgsMapLayer *currentLayer();
private: private:
QListView * listView; QListView * listView;

View File

@ -413,9 +413,8 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
switch (mapTool) { switch (mapTool) {
case QGis::Identify: case QGis::Identify:
// call identify method for selected layer // call identify method for selected layer
QString lyrName = mapLegend->currentLayer(); QgsMapLayer * lyr = mapLegend->currentLayer();
if (!lyrName.isEmpty()) { if (lyr) {
QgsMapLayer *lyr = layers[lyrName];
// create the search rectangle // create the search rectangle
double searchRadius = extent().width() * .005; double searchRadius = extent().width() * .005;
QgsRect *search = new QgsRect(); QgsRect *search = new QgsRect();
@ -432,6 +431,8 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
"To identify features, you must choose an layer active by clicking on its name in the legend"); "To identify features, you must choose an layer active by clicking on its name in the legend");
} }
break; break;
} }
} }
} }

View File

@ -148,3 +148,7 @@ void QgsMapLayer::setFeatureType(const int &_newVal)
void QgsMapLayer::identify(QgsRect * r) void QgsMapLayer::identify(QgsRect * r)
{ {
} }
void QgsMapLayer::table()
{
}

View File

@ -34,8 +34,7 @@
*/ */
class QgsMapLayer:public QObject class QgsMapLayer:public QObject
{ {
Q_OBJECT Q_OBJECT public:
public:
/*! Constructor /*! Constructor
* @param type Type of layer as defined in LAYERS enum * @param type Type of layer as defined in LAYERS enum
* @param lyrname Display Name of the layer * @param lyrname Display Name of the layer
@ -67,6 +66,9 @@ class QgsMapLayer:public QObject
/*! Identify the feature(s) in this layer that are contained in the search rectangle /*! Identify the feature(s) in this layer that are contained in the search rectangle
*/ */
virtual void identify(QgsRect *); virtual void identify(QgsRect *);
/*! Display the attribute table for the layer
*/
virtual void table();
/*! Return the extent of the layer as a QRect /*! Return the extent of the layer as a QRect
*/ */
const QgsRect extent(); const QgsRect extent();
@ -105,8 +107,7 @@ class QgsMapLayer:public QObject
RASTER, RASTER,
DATABASE DATABASE
}; };
signals: signals:void visibilityChanged(void);
void visibilityChanged(void);
protected: protected:
//! Extent of the layer //! Extent of the layer
QgsRect layerExtent; QgsRect layerExtent;

View File

@ -17,13 +17,19 @@
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <strstream> #include <strstream>
#include <qapplication.h>
#include <qcursor.h>
#include <qpainter.h> #include <qpainter.h>
#include <qpointarray.h> #include <qpointarray.h>
#include <qstring.h> #include <qstring.h>
#include <qmessagebox.h>
#include "qgsrect.h" #include "qgsrect.h"
#include "qgspoint.h" #include "qgspoint.h"
#include "qgscoordinatetransform.h" #include "qgscoordinatetransform.h"
#include "qgsshapefilelayer.h" #include "qgsshapefilelayer.h"
#include "qgsidentifyresults.h"
#include "qgsattributetable.h"
#include "qgsattributetabledisplay.h"
#include <ogrsf_frmts.h> #include <ogrsf_frmts.h>
#include <ogr_geometry.h> #include <ogr_geometry.h>
@ -267,4 +273,89 @@ int QgsShapeFileLayer::endian()
void QgsShapeFileLayer::identify(QgsRect * r) void QgsShapeFileLayer::identify(QgsRect * r)
{ {
OGRGeometry *filter = 0;
filter = new OGRPolygon();
std::ostrstream wktExtent;
wktExtent << "POLYGON ((" << r->stringRep() << "))" << ends;
char *wktText = wktExtent.str();
OGRErr result = ((OGRPolygon *) filter)->importFromWkt(&wktText);
if (result == OGRERR_NONE) {
ogrLayer->SetSpatialFilter(filter);
int featureCount = 0;
// just id the first feature for now
//while (OGRFeature * fet = ogrLayer->GetNextFeature()) {
//}
OGRFeature *fet = ogrLayer->GetNextFeature();
if (fet) {
// found feature - show it in the identify box
QgsIdentifyResults *ir = new QgsIdentifyResults();
// just show one result - modify this later
int numFields = fet->GetFieldCount();
for (int i = 0; i < numFields; i++) {
// get the field definition
OGRFieldDefn *fldDef = fet->GetFieldDefnRef(i);
QString fld = fldDef->GetNameRef();
OGRFieldType fldType = fldDef->GetType();
QString val;
//if(fldType == 16604 ) // geometry
val = "(geometry column)";
// else
val = fet->GetFieldAsString(i);
ir->addAttribute(fld, val);
}
ir->setTitle(name());
ir->show();
} else {
QMessageBox::information(0, "No features found", "No features were found in the active layer at the point you clicked");
}
}
}
void QgsShapeFileLayer::table()
{
// display the attribute table
QApplication::setOverrideCursor(Qt::waitCursor);
ogrLayer->SetSpatialFilter(0);
OGRFeature *fet = ogrLayer->GetNextFeature();
int numFields = fet->GetFieldCount();
QgsAttributeTableDisplay *at = new QgsAttributeTableDisplay();
at->table()->setNumRows(ogrLayer->GetFeatureCount(true));
at->table()->setNumCols(numFields);
int row = 0;
// set up the column headers
QHeader *colHeader = at->table()->horizontalHeader();
for (int h = 0; h < numFields; h++) {
OGRFieldDefn *fldDef = fet->GetFieldDefnRef(h);
QString fld = fldDef->GetNameRef();
colHeader->setLabel(h, fld);
}
while (fet) {
for (int i = 0; i < numFields; i++) {
// get the field values
QString val;
//if(fldType == 16604 ) // geometry
val = "(geometry column)";
// else
val = fet->GetFieldAsString(i);
at->table()->setText(row, i, val);
}
row++;
delete fet;
fet = ogrLayer->GetNextFeature();
}
at->table()->setSorting(true);
at->setTitle("Attribute table - " + name());
QApplication::restoreOverrideCursor();
at->show();
} }

View File

@ -29,34 +29,40 @@ class OGRDataSource;
* \brief Shapefile layer * \brief Shapefile layer
*/ */
class QgsShapeFileLayer : public QgsMapLayer { class QgsShapeFileLayer:public QgsMapLayer
Q_OBJECT {
public: Q_OBJECT public:
//! Constructor //! Constructor
QgsShapeFileLayer(QString baseName = 0, QString path = 0); QgsShapeFileLayer(QString baseName = 0, QString path = 0);
//! Destructor //! Destructor
~QgsShapeFileLayer(); ~QgsShapeFileLayer();
//! Identify feature found within the search rectangle
void identify(QgsRect *); void identify(QgsRect *);
//! Display the attribute table
enum SHAPETYPE { void table();
enum SHAPETYPE
{
Point, Point,
Line, Line,
Polygon Polygon
}; };
private: // Private attributes private: // Private attributes
//! Draws the layer using coordinate transformation
void draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf); void draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf);
OGRDataSource *ogrDataSource; OGRDataSource *ogrDataSource;
OGRLayer *ogrLayer; OGRLayer *ogrLayer;
/** */ /** */
bool registered; bool registered;
enum ENDIAN{ enum ENDIAN
{
NDR = 1, NDR = 1,
XDR = 0 XDR = 0
}; };
enum WKBTYPE{ enum WKBTYPE
{
WKBPoint = 1, WKBPoint = 1,
WKBLineString, WKBLineString,
WKBPolygon, WKBPolygon,

View File

@ -30,7 +30,9 @@ HEADERS += qgsdbsourceselectbase.ui.h \
qgslegend.h \ qgslegend.h \
qgslegenditem.h \ qgslegenditem.h \
qgslayerproperties.h \ qgslayerproperties.h \
qgsidentifyresults.h qgsidentifyresults.h \
qgsattributetable.h \
qgsattributetabledisplay.h
INTERFACES += qgsdbsourceselectbase.ui \ INTERFACES += qgsdbsourceselectbase.ui \
qgisappbase.ui \ qgisappbase.ui \
@ -38,7 +40,8 @@ INTERFACES += qgsdbsourceselectbase.ui \
qgslegenditembase.ui \ qgslegenditembase.ui \
qgsabout.ui \ qgsabout.ui \
qgslayerpropertiesbase.ui \ qgslayerpropertiesbase.ui \
qgsidentifyresultsbase.ui qgsidentifyresultsbase.ui \
qgsattributetablebase.ui
SOURCES += main.cpp \ SOURCES += main.cpp \
qgisapp.cpp \ qgisapp.cpp \
qgsdatabaselayer.cpp \ qgsdatabaselayer.cpp \
@ -59,4 +62,6 @@ SOURCES += main.cpp \
qgslinesymbol.cpp \ qgslinesymbol.cpp \
qgspolygonsymbol.cpp \ qgspolygonsymbol.cpp \
qgslayerproperties.cpp \ qgslayerproperties.cpp \
qgsidentifyresults.cpp qgsidentifyresults.cpp \
qgsattributetable.cpp \
qgsattributetabledisplay.cpp