-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv2vector.py
55 lines (44 loc) · 2.17 KB
/
csv2vector.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
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from csv2vector_controller import Csv2vectorDialog
class Csv2VectorPlugin:
def __init__(self, iface):
self.iface = iface
#i18n
pluginPath = QFileInfo(os.path.realpath(__file__)).path()
overrideLocale = QSettings().value("locale/overrideFlag", False)
if not overrideLocale:
localeName = QLocale.system().name()
else:
localeName = QSettings().value("locale/userLocale", "")
if QFileInfo(pluginPath).exists():
self.localePath = pluginPath+"/i18n/csv2vector_" + localeName + ".qm"
if QFileInfo(self.localePath).exists():
self.translator = QTranslator()
self.translator.load(self.localePath)
QCoreApplication.installTranslator(self.translator)
def initGui(self):
self.action = QAction( QIcon(":/plugins/csv2vector/x_office_spreadsheet.png"), "CSV2Vector", self.iface.mainWindow())
self.action.setWhatsThis( QCoreApplication.translate("CSV2Vector", "Create points shapefile from csv file"))
self.action.setStatusTip( QCoreApplication.translate("CSV2Vector", "Create points shapefile from csv file"))
QObject.connect(self.action, SIGNAL("triggered()"), self.run)
if hasattr( self.iface, "addPluginToVectorMenu" ):
self.iface.addPluginToVectorMenu( QCoreApplication.translate("CSV2Vector","CSV2Vector"), self.action )
self.iface.addVectorToolBarIcon( self.action )
else:
self.iface.addPluginToMenu( QCoreApplication.translate("CSV2Vector","CSV2Vector"), self.action )
self.iface.addToolBarIcon( self.action )
def unload(self):
self.iface.removePluginMenu("&Test plugins",self.action)
self.iface.removeToolBarIcon(self.action)
if hasattr( self.iface, "addPluginToVectorMenu" ):
self.iface.removePluginVectorMenu( QCoreApplication.translate("CSV2Vector","CSV2Vector"), self.action )
self.iface.removeVectorToolBarIcon( self.action )
else:
self.iface.removePluginMenu( QCoreApplication.translate("CSV2Vector","CSV2Vector"), self.action )
self.iface.removeToolBarIcon( self.action )
def run(self):
uid = Csv2vectorDialog()
uid.exec_()