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

@ -1,5 +1,5 @@
#ifndef QGIS_H #ifndef QGIS_H
#define QGIS_H #define QGIS_H
/*! \mainpage Quantum GIS /*! \mainpage Quantum GIS
* *
* \section about About QGis * \section about About QGis
@ -10,23 +10,27 @@
* *
*/ */
namespace QGis { namespace QGis
enum MapTools { {
ZoomIn, enum MapTools
ZoomOut, {
Pan, ZoomIn,
Distance, ZoomOut,
Identify Pan,
}; Distance,
Identify,
Table
};
//! Used for symbology operations //! Used for symbology operations
enum WKBTYPE{ enum WKBTYPE
WKBPoint=1, {
WKBLineString, WKBPoint = 1,
WKBPolygon, WKBLineString,
WKBMultiPoint, WKBPolygon,
WKBMultiLineString, WKBMultiPoint,
WKBMultiPolygon WKBMultiLineString,
}; WKBMultiPolygon
};
} }
#endif #endif

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

@ -148,14 +148,14 @@ QgisApp::QgisApp(QWidget * parent, const char *name, WFlags fl):QgisAppBase(pare
// create the layer popup menu // create the layer popup menu
popMenu = new QPopupMenu(); popMenu = new QPopupMenu();
popMenu->insertItem("&Zoom to extent of selected layer", this, SLOT(zoomToLayerExtent())); popMenu->insertItem("&Zoom to extent of selected layer", this, SLOT(zoomToLayerExtent()));
popMenu->insertItem("&Remove", this, SLOT(removeLayer())); popMenu->insertItem("&Remove", this, SLOT(removeLayer()));
popMenu->insertItem("&Properties", this, SLOT(layerProperties())); popMenu->insertItem("&Properties", this, SLOT(layerProperties()));
mapCursor = 0; mapCursor = 0;
// set the legend control for the map canvas // set the legend control for the map canvas
mapCanvas->setLegend(mapLegend); mapCanvas->setLegend(mapLegend);
// connect the "cleanup" slot // connect the "cleanup" slot
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveWindowState())); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveWindowState()));
restoreWindowState(); restoreWindowState();
@ -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,15 +561,16 @@ 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();
QgsMapLayer *lyr = ((QgsLegendItem *) li)->layer(); QgsMapLayer *lyr = ((QgsLegendItem *) li)->layer();
mapCanvas->setExtent(lyr->extent()); mapCanvas->setExtent(lyr->extent());
mapCanvas->clear(); mapCanvas->clear();
mapCanvas->render2(); mapCanvas->render2();
} }
void QgisApp::rightClickLegendMenu(QListViewItem * lvi, const QPoint & pt, int) void QgisApp::rightClickLegendMenu(QListViewItem * lvi, const QPoint & pt, int)
@ -585,8 +599,8 @@ void QgisApp::testPluginFunctions()
std::cout << "Plugin name: " << pl->name() << std::endl; std::cout << "Plugin name: " << pl->name() << std::endl;
std::cout << "Plugin version: " << pl->version() << std::endl; std::cout << "Plugin version: " << pl->version() << std::endl;
std::cout << "Plugin description: " << pl->description() << std::endl; std::cout << "Plugin description: " << pl->description() << std::endl;
QMessageBox::information(this,"Plugin Information","QGis loaded the following plugin:\nName: " QMessageBox::information(this, "Plugin Information", "QGis loaded the following plugin:\nName: "
+ pl->name() + "\nVersion: " + pl->version() + "\nDescription: " + pl->description()); + pl->name() + "\nVersion: " + pl->version() + "\nDescription: " + pl->description());
// unload the plugin (delete it) // unload the plugin (delete it)
std::cout << "Attempting to resolve the unload function" << std::endl; std::cout << "Attempting to resolve the unload function" << std::endl;
unload_t *ul = (unload_t *) myLib.resolve("unload"); unload_t *ul = (unload_t *) myLib.resolve("unload");
@ -594,13 +608,14 @@ void QgisApp::testPluginFunctions()
ul(pl); ul(pl);
std::cout << "Unloaded the plugin\n"; std::cout << "Unloaded the plugin\n";
} else { } else {
std::cout << "Unable to resolve unload function. Plugin was not unloaded\n"; std::cout << "Unable to resolve unload function. Plugin was not unloaded\n";
} }
} }
} 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",
std::cout << "Unable to load library" << std::endl; "QGis was unable to load the plugin from: ../plugins/libqgisplugin.so.1.0.0");
} std::cout << "Unable to load library" << std::endl;
}
} }
void QgisApp::saveWindowState() void QgisApp::saveWindowState()
@ -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,13 +35,13 @@ 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);
~QgisApp(); ~QgisApp();
//public slots: //public slots:
//! Add a layer to the map //! Add a layer to the map
void addLayer(); void addLayer();
@ -50,16 +50,19 @@ public:
//! Exit Qgis //! Exit Qgis
void fileExit(); void fileExit();
//! Set map tool to Zoom out //! Set map tool to Zoom out
void zoomOut(); void zoomOut();
//! Set map tool to Zoom in //! Set map tool to Zoom in
void zoomIn(); void zoomIn();
//! Zoom to full extent //! Zoom to full extent
void zoomFull(); void zoomFull();
//! Zoom to the previous extent //! Zoom to the previous extent
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
@ -70,8 +73,8 @@ public:
void testButton(); void testButton();
//! About QGis //! About QGis
void about(); void about();
public slots: public slots:
//! Slot to show the map coordinate position of the mouse cursor //! Slot to show the map coordinate position of the mouse cursor
void showMouseCoordinate(QgsPoint &); void showMouseCoordinate(QgsPoint &);
//! Show layer properties for the selected layer //! Show layer properties for the selected layer
@ -79,34 +82,34 @@ public slots:
//! Show layer properties for selected layer (called by right-click menu) //! Show layer properties for selected layer (called by right-click menu)
void layerProperties(); void layerProperties();
//! Show the right-click menu for the legend //! Show the right-click menu for the legend
void rightClickLegendMenu(QListViewItem *, const QPoint &, int ); void rightClickLegendMenu(QListViewItem *, const QPoint &, int);
//! Remove a layer from the map and legend //! Remove a layer from the map and legend
void removeLayer(); void removeLayer();
//! zoom to extent of layer //! zoom to extent of layer
void zoomToLayerExtent(); void zoomToLayerExtent();
//! test plugin functionality //! test plugin functionality
void testPluginFunctions(); void testPluginFunctions();
//! Save window state //! Save window state
void saveWindowState(); void saveWindowState();
//! Restore the window and toolbar state //! Restore the window and toolbar state
void restoreWindowState(); void restoreWindowState();
private: private:
//! Popup menu //! Popup menu
QPopupMenu *popMenu; QPopupMenu * popMenu;
//! Legend list view control //! Legend list view control
QListView *legendView; QListView *legendView;
//! Map canvas //! Map canvas
QgsMapCanvas *mapCanvas; QgsMapCanvas *mapCanvas;
//! Table of contents (legend) for the map //! Table of contents (legend) for the map
QgsLegend *mapLegend; QgsLegend *mapLegend;
QCursor *mapCursor; QCursor *mapCursor;
//! scale factor //! scale factor
double scaleFactor; double scaleFactor;
//! Current map window extent in real-world coordinates //! Current map window extent in real-world coordinates
QRect *mapWindow; QRect *mapWindow;
//! Current map tool //! Current map tool
int mapTool; int mapTool;
QCursor *cursorZoomIn; QCursor *cursorZoomIn;
}; };
#endif #endif

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
@ -420,14 +425,14 @@ void QgsDatabaseLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTra
void QgsDatabaseLayer::identify(QgsRect * r) void QgsDatabaseLayer::identify(QgsRect * r)
{ {
// create a search filter for identifying records // create a search filter for identifying records
QString sql = "select * from " + tableName; QString sql = "select * from " + tableName;
sql += " where " + geometryColumn; sql += " where " + geometryColumn;
sql += " && GeometryFromText('BOX3D(" + r->stringRep(); sql += " && GeometryFromText('BOX3D(" + r->stringRep();
sql += ")'::box3d,-1)"; sql += ")'::box3d,-1)";
qWarning(sql); qWarning(sql);
// select the features // select the features
PgCursor pgs(dataSource, "identifyCursor"); PgCursor pgs(dataSource, "identifyCursor");
pgs.Declare((const char *) sql, false); pgs.Declare((const char *) sql, false);
int res = pgs.Fetch(); int res = pgs.Fetch();
@ -435,28 +440,74 @@ void QgsDatabaseLayer::identify(QgsRect * r)
QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl; QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl;
// qWarning(msg); // qWarning(msg);
// std::cout << "Using following transform parameters:\n" << cXf->showParameters() << std::endl; // std::cout << "Using following transform parameters:\n" << cXf->showParameters() << std::endl;
// create the results window // create the results window
if(pgs.Tuples() > 0){ if (pgs.Tuples() > 0) {
QgsIdentifyResults *ir = new QgsIdentifyResults(); QgsIdentifyResults *ir = new QgsIdentifyResults();
// just show one result - modify this later // just show one result - modify this later
int numFields = pgs.Fields(); int numFields = pgs.Fields();
for(int i = 0; i < numFields; i++){ for (int i = 0; i < numFields; i++) {
QString fld = pgs.FieldName(i); QString fld = pgs.FieldName(i);
int fldType = pgs.FieldType(i); int fldType = pgs.FieldType(i);
QString val; QString val;
if(fldType == 16604 ) // geometry if (fldType == 16604) // geometry
val = "(geometry column)"; val = "(geometry column)";
else else
val = pgs.GetValue(0,i); val = pgs.GetValue(0, i);
ir->addAttribute(fld, val); ir->addAttribute(fld, val);
} }
ir->show(); 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");
}
}else{
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,46 +27,52 @@ 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
*@param table Name of the table in the database that this layer *@param table Name of the table in the database that this layer
* represents * represents
*/ */
QgsDatabaseLayer(const char *conninfo=0, QString table=QString::null); QgsDatabaseLayer(const char *conninfo = 0, QString table = QString::null);
//! Destructor //! Destructor
~QgsDatabaseLayer(); ~QgsDatabaseLayer();
virtual void draw(QPainter *, QgsRect *, int ); //! Deprecated draw function
virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform *cFx); virtual void draw(QPainter *, QgsRect *, int);
void identify(QgsRect *); //! Draws the layer using coordinate transformation
private: virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * cFx);
//! Calculates extent of the layer using SQL and PostGIS functions //! Identify the feature found within the search rectangle
QgsRect calculateExtent(); void identify(QgsRect *);
//! Type geometry contained in the layer. This corresponds to one of the OGIS Simple geometry types //! Display the attribute table
QString type; void table();
//! WKB type private:
int wkbType; //! Calculates extent of the layer using SQL and PostGIS functions
//! Name of the database containing the layer (table) QgsRect calculateExtent();
QString database; //! Type geometry contained in the layer. This corresponds to one of the OGIS Simple geometry types
//! Name of the table containing the features QString type;
QString tableName; //! WKB type
//! Name of the column in the table that contains the geometry for the features int wkbType;
QString geometryColumn; //! Name of the database containing the layer (table)
//OGIS WKB types QString database;
//! Name of the table containing the features
enum ENDIAN{ QString tableName;
NDR=1, //! Name of the column in the table that contains the geometry for the features
XDR=0 QString geometryColumn;
}; //OGIS WKB types
//! Returns the endian type for the client
int endian(); enum ENDIAN
/*! Endian type as string {
* @return XDR or NDR NDR = 1,
*/ XDR = 0
QString endianString(); };
//! Returns the endian type for the client
int endian();
/*! Endian type as string
* @return XDR or NDR
*/
QString endianString();
}; };
#endif #endif

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()
QListViewItem *li = listView->currentItem(); {
if(li) QgsLegendItem *li = (QgsLegendItem *) listView->currentItem();
return li->text(0);
else if (li)
return 0; return li->layer();
} else
return 0;
}
QString QgsLegend::currentLayerName()
{
QListViewItem *li = listView->currentItem();
if (li)
return li->text(0);
else
return 0;
}
void QgsLegend::update() void QgsLegend::update()
{ {
// clear the legend // clear the legend

View File

@ -32,26 +32,28 @@ 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
* @param name Name of the widget * @param name Name of the widget
*/ */
QgsLegend(QListView *lv, QWidget *parent=0, const char *name=0); QgsLegend(QListView * lv, QWidget * parent = 0, const char *name = 0);
//! Destructor //! Destructor
~QgsLegend(); ~QgsLegend();
//! Set the pointer to the map canvas //! Set the pointer to the map canvas
void setMapCanvas(QgsMapCanvas *canvas); void setMapCanvas(QgsMapCanvas * canvas);
//! Update the legend //! Update the legend
void update(); void update();
QString currentLayer(); QString currentLayerName();
private: QgsMapLayer *currentLayer();
QListView* listView;
QgsMapCanvas *map; private:
QListView * listView;
QgsMapCanvas *map;
}; };
#endif #endif

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

@ -27,7 +27,7 @@ QgsMapLayer::QgsMapLayer(int type, QString lyrname, QString source):layerName(ly
valid = true; valid = true;
m_visible = true; m_visible = true;
// create a default symbol // create a default symbol
// Generate the unique ID of this layer // Generate the unique ID of this layer
QDateTime dt = QDateTime::currentDateTime(); QDateTime dt = QDateTime::currentDateTime();
ID = lyrname + dt.toString("yyyyMMddhhmmsszzz"); ID = lyrname + dt.toString("yyyyMMddhhmmsszzz");
@ -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
@ -64,9 +63,12 @@ class QgsMapLayer:public QObject
virtual QgsRect calculateExtent(); virtual QgsRect calculateExtent();
virtual void draw(QPainter *, QgsRect *, int); virtual void draw(QPainter *, QgsRect *, int);
virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * cXf); virtual void draw(QPainter *, QgsRect *, QgsCoordinateTransform * cXf);
/*! 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;
@ -118,10 +119,10 @@ class QgsMapLayer:public QObject
int feature; int feature;
private: // Private attributes private: // Private attributes
/** Unique ID of this layer - used to refer to this layer in QGIS code */ /** Unique ID of this layer - used to refer to this layer in QGIS code */
QString ID; QString ID;
/** Name of the layer - used for display */ /** Name of the layer - used for display */
QString layerName; QString layerName;
/** Type of the layer (eg. vector, raster, database */ /** Type of the layer (eg. vector, raster, database */
int layerType; int layerType;

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,46 +29,52 @@ 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();
void identify(QgsRect *); //! Identify feature found within the search rectangle
void identify(QgsRect *);
enum SHAPETYPE { //! Display the attribute table
Point, void table();
Line, enum SHAPETYPE
Polygon {
}; Point,
Line,
Polygon
};
private: // Private attributes private: // Private attributes
void draw(QPainter *p, QgsRect *viewExtent, QgsCoordinateTransform *cXf); //! Draws the layer using coordinate transformation
OGRDataSource *ogrDataSource; void draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTransform * cXf);
OGRDataSource *ogrDataSource;
OGRLayer *ogrLayer;
OGRLayer *ogrLayer;
/** */ /** */
bool registered; bool registered;
enum ENDIAN{ enum ENDIAN
NDR=1, {
XDR=0 NDR = 1,
}; XDR = 0
enum WKBTYPE{ };
WKBPoint=1, enum WKBTYPE
WKBLineString, {
WKBPolygon, WKBPoint = 1,
WKBMultiPoint, WKBLineString,
WKBMultiLineString, WKBPolygon,
WKBMultiPolygon WKBMultiPoint,
}; WKBMultiLineString,
private: // Private methods WKBMultiPolygon
};
private: // Private methods
/** No descriptions */ /** No descriptions */
void registerFormats(); void registerFormats();
int endian(); int endian();
}; };
#endif #endif

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 \
@ -46,7 +49,7 @@ SOURCES += main.cpp \
qgsmapcanvas.cpp \ qgsmapcanvas.cpp \
qgsmaplayer.cpp \ qgsmaplayer.cpp \
qgsrasterlayer.cpp \ qgsrasterlayer.cpp \
qgsshapefilelayer.cpp \ qgsshapefilelayer.cpp \
qgsdbsourceselect.cpp \ qgsdbsourceselect.cpp \
qgsnewconnection.cpp \ qgsnewconnection.cpp \
qgsrect.cpp \ qgsrect.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