This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
cswclient.py
146 lines (122 loc) · 6.69 KB
/
cswclient.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# -*- coding: utf-8 -*-
#******************************************************************************
#
# CSW Client
# ---------------------------------------------------------
# QGIS Catalogue Service client.
#
# Copyright (C) 2010 NextGIS (http://nextgis.org),
# Alexander Bruy ([email protected]),
# Maxim Dubinin ([email protected])
#
# This source is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This code is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# A copy of the GNU General Public License is available on the World Wide Web
# at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
# to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.
#
#******************************************************************************
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
import cswclientdialog
from __init__ import version
import resources_rc
class CSWClientPlugin( object ):
def __init__( self, iface ):
self.iface = iface
self.iface = iface
try:
self.QgisVersion = unicode( QGis.QGIS_VERSION_INT )
except:
self.QgisVersion = unicode( QGis.qgisVersion )[ 0 ]
# For i18n support
userPluginPath = QFileInfo( QgsApplication.qgisUserDbFilePath() ).path() + "/python/plugins/cswclient"
systemPluginPath = QgsApplication.prefixPath() + "/python/plugins/cswclient"
overrideLocale = QSettings().value( "locale/overrideFlag", QVariant( False ) ).toBool()
if not overrideLocale:
localeFullName = QLocale.system().name()
else:
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
if QFileInfo( userPluginPath ).exists():
translationPath = userPluginPath + "/i18n/cswclient_" + localeFullName + ".qm"
else:
translationPath = systemPluginPath + "/i18n/cswclient_" + localeFullName + ".qm"
self.localePath = translationPath
if QFileInfo( self.localePath ).exists():
self.translator = QTranslator()
self.translator.load( self.localePath )
QCoreApplication.installTranslator( self.translator )
def initGui( self ):
if int( self.QgisVersion ) < 1:
QMessageBox.warning( self.iface.mainWindow(), "CSW Client",
QCoreApplication.translate( "CSW Client", "Quantum GIS version detected: " ) + unicode( self.QgisVersion ) + ".xx\n" +
QCoreApplication.translate( "CSW Client", "This version of CSW Client requires at least QGIS version 1.0.0\nPlugin will not be enabled." ) )
return None
self.actionRun = QAction( QIcon( ":/cswclient.png" ), "CSW Client", self.iface.mainWindow() )
self.actionRun.setStatusTip( QCoreApplication.translate( "CSW Client", "Perform search in Catalogue Services" ) )
self.actionAbout = QAction( QIcon( ":/about.png" ), "About", self.iface.mainWindow() )
QObject.connect( self.actionRun, SIGNAL( "triggered()" ), self.run )
QObject.connect( self.actionAbout, SIGNAL( "triggered()" ), self.about )
if hasattr( self.iface, "addPluginToWebMenu" ):
self.iface.addPluginToWebMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionRun )
self.iface.addPluginToWebMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionAbout )
self.iface.addWebToolBarIcon( self.actionRun )
else:
self.iface.addPluginToMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionRun )
self.iface.addPluginToMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionAbout )
self.iface.addToolBarIcon( self.actionRun )
def unload( self ):
if hasattr( self.iface, "addPluginToWebMenu" ):
self.iface.removePluginWebMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionRun )
self.iface.removePluginWebMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionAbout )
self.iface.removeWebToolBarIcon( self.actionRun )
else:
self.iface.removePluginMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionRun )
self.iface.removePluginMenu( QCoreApplication.translate( "CSW Client", "CSW Client" ), self.actionAbout )
self.iface.removeToolBarIcon( self.actionRun )
def about( self ):
dlgAbout = QDialog()
dlgAbout.setWindowTitle( QApplication.translate( "CSW Client", "About CSW Client", "Window title" ) )
lines = QVBoxLayout( dlgAbout )
title = QLabel( QApplication.translate( "CSW Client", "<b>CSW Client</b>" ) )
title.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
lines.addWidget( title )
version = QLabel( QApplication.translate( "CSW Client", "Version: %1" ).arg( version() ) )
version.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
lines.addWidget( version )
lines.addWidget( QLabel( QApplication.translate( "CSW Client", "Catalogue Services browser. Provide\ninterface for discovering and retrieval\nof spatial data and services metadata." ) ) )
lines.addWidget( QLabel( QApplication.translate( "CSW Client", "<b>Developers:</b>" ) ) )
lines.addWidget( QLabel( " <a href=\"http://nextgis.ru\">NextGIS</a>" ) )
lines.addWidget( QLabel( " Alexander Bruy" ) )
lines.addWidget( QLabel( " Maxim Dubinin" ) )
lines.addWidget( QLabel( QApplication.translate( "CSW Client", "<b>Homepage:</b>") ) )
overrideLocale = QSettings().value( "locale/overrideFlag", QVariant( False ) ).toBool()
if not overrideLocale:
localeFullName = QLocale.system().name()
else:
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
localeShortName = localeFullName[ 0:2 ]
if localeShortName in [ "ru", "uk" ]:
link = QLabel( "<a href=\"http://gis-lab.info/qa/cswclient.html\">http://gis-lab.info/qa/cswclient.html</a>" )
else:
link = QLabel( "<a href=\"http://gis-lab.info/qa/cswclient-eng.html\">http://gis-lab.info/qa/cswclient-eng.html</a>" )
link.setOpenExternalLinks( True )
lines.addWidget( link )
btnClose = QPushButton( QApplication.translate( "CSW Client", "Close" ) )
lines.addWidget( btnClose )
QObject.connect( btnClose, SIGNAL( "clicked()" ), dlgAbout, SLOT( "close()" ) )
dlgAbout.exec_()
def run( self ):
dlg = cswclientdialog.CSWClientDialog( self.iface )
dlg.exec_()