src/terralib/qt/plugins/mobile/Plugin.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file src/terraMobilePlugin/Plugin.cpp
22 
23  \brief Plugin implementation for the RP Qt Plugin widget.
24 */
25 
26 // TerraLib
27 #include "../../../core/translator/Translator.h"
28 #include "../../../core/logger/Logger.h"
29 #include "../../../common/StringUtils.h"
30 #include "../../../dataaccess/datasource/DataSourceFactory.h"
31 #include "../../../dataaccess/datasource/DataSourceManager.h"
32 #include "../../../dataaccess/query/BinaryOpEncoder.h"
33 #include "../../../dataaccess/query/FunctionEncoder.h"
34 #include "../../../dataaccess/query/UnaryOpEncoder.h"
35 #include "../../../dataaccess/query/SQLDialect.h"
36 #include "../../../qt/af/ApplicationController.h"
37 #include "../mobile/geopackage/DataSource.h"
38 
39 #include "Plugin.h"
40 
41 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGEBUILDER
42  #include "GeoPackageBuilderAction.h"
43 #endif
44 
45 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGEPUBLISHER
47 #endif
48 
49 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGESYNCHRONIZER
51 #endif
52 
53 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_CREATELAYER
54 #include "CreateLayerAction.h"
55 #endif
56 
57 // QT
58 #include <QMenu>
59 #include <QMenuBar>
60 
62  : te::core::CppPlugin(pluginInfo), m_menu(0)
63 {
64 }
65 
67 {
68 }
69 
71 {
72  if(m_initialized)
73  return;
74 
76 
77  TE_LOG_TRACE(TE_TR("Terra Mobile Plugin startup!"));
78 
79 // add plugin menu
80  m_menu = te::qt::af::AppCtrlSingleton::getInstance().getMenu("terramobile");
81 
82  m_menu->setTitle(TE_TR("Mobile"));
83 
84 // add pop up menu
85  m_popupAction = new QAction(m_menu);
86  m_popupAction->setText(TE_TR("Mobile"));
87 
88 // register actions
90 
91  //gpkg
92 
93  // it initializes the OGR Factory support
95 
96  //define dialect
98 
99  mydialect->insert("+", new te::da::BinaryOpEncoder("+"));
100  mydialect->insert("-", new te::da::BinaryOpEncoder("-"));
101  mydialect->insert("*", new te::da::BinaryOpEncoder("*"));
102  mydialect->insert("/", new te::da::BinaryOpEncoder("/"));
103  mydialect->insert("=", new te::da::BinaryOpEncoder("="));
104  mydialect->insert("<>", new te::da::BinaryOpEncoder("<>"));
105  mydialect->insert(">", new te::da::BinaryOpEncoder(">"));
106  mydialect->insert("<", new te::da::BinaryOpEncoder("<"));
107  mydialect->insert(">=", new te::da::BinaryOpEncoder(">="));
108  mydialect->insert("<=", new te::da::BinaryOpEncoder("<="));
109  mydialect->insert("and", new te::da::BinaryOpEncoder("AND"));
110  mydialect->insert("or", new te::da::BinaryOpEncoder("OR"));
111  mydialect->insert("not", new te::da::UnaryOpEncoder("NOT"));
112 
113  mydialect->insert("st_envelopeintersects", new te::da::FunctionEncoder("Intersection"));
114 
116 
117  m_initialized = true;
118 }
119 
121 {
122  if(!m_initialized)
123  return;
124 
125 // remove menu
126  delete m_menu;
127 
128 // unregister actions
130 
131  // it finalizes the OGR factory support.
133 
134  // free OGR registered drivers
136 
138 
139  TE_LOG_TRACE(TE_TR("Terra Mobile Plugin shutdown!"));
140 
141  m_initialized = false;
142 }
143 
145 {
146 
147 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGEBUILDER
150 #endif
151 
152 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGEPUBLISHER
155 #endif
156 
157 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGESYNCHRONIZER
160 #endif
161 
162 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_CREATELAYER
163  m_menu->addSeparator();
166 #endif
167 
168 }
169 
171 {
172 
173 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGEBUILDER
174  delete m_gpBuider;
175 #endif
176 
177 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GEOPACKAGEPUBLISHER
178  delete m_gpPublisher;
179 #endif
180 
181 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_GATHERINGLAYERCONFIGURER
182  delete m_gpSync;
183 #endif
184 
185 #ifdef TE_QT_PLUGIN_TERRAMOBILE_HAVE_CREATELAYER
186  delete m_createLayer;
187 #endif
188 
189 }
190 
QMenu * m_menu
thirdParty Main Menu registered.
te::qt::plugins::terramobile::CreateLayerAction * m_createLayer
Used to create a new layer.
te::qt::plugins::terramobile::GeoPackagePublisherAction * m_gpPublisher
GeoPackage Publisher Operation Process Action.
te::qt::plugins::terramobile::GeoPackageBuilderAction * m_gpBuider
GeoPackage Builder Operation Process Action.
QAction * m_popupAction
thirdParty pop up action registered.
An SQL encoder for general function expressions.
This file defines the Create Layer Action class.
A base class for application events.
void triggered(te::qt::af::evt::Event *e)
This file defines the GeoPackage Publisher Action class.
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:55
void shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.
Basic information about a plugin.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
void registerActions()
Function used to register all terra mobile actions.
static void remove(const std::string &dsType)
it finalizes the GDAL factory support.
void insert(const std::string &funcName, SQLFunctionEncoder *encoder)
It adds a new encoder for a given function.
Definition: SQLDialect.cpp:38
A query encoder for binary operations.
te::da::SQLDialect * mydialect
Definition: OGRDialect.h:1
This file defines the GeoPackage Builder Action class.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
This file defines the GeoPackage Synchronizer Action class.
URI C++ Library.
Definition: Attributes.h:37
#define GPKG_DRIVER_IDENTIFIER
The OGR driver identifier string.
#define TERRALIB_PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME)
This macro should be used by C++ plugins in order to declare the exportable/callable DLL function...
te::qt::plugins::terramobile::GeoPackageSynchronizerAction * m_gpSync
GeoPackage Synchronizer Operation Process Action.
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
A query encoder for unary operator expressions.
#define TE_LOG_TRACE(message)
Use this tag in order to log a message to the TerraLib default logger with the TRACE level...
Definition: Logger.h:293
static void add(const std::string &dsType, FactoryFnctType f)
static void setDialect(te::da::SQLDialect *dialect)
void unRegisterActions()
Function used to unregister all terra mobile actions.