src/terralib/qt/plugins/datasource/terralib4/Plugin.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 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 terralib/qt/plugins/terralib4/Plugin.cpp
22 
23  \brief Plugin implementation for the TERRALIB4 Qt Plugin widget.
24 */
25 
26 // TerraLib
27 #include "../../../../common/Config.h"
28 #include "../../../../core/translator/Translator.h"
29 #include "../../../../core/logger/Logger.h"
30 #include "../../../af/ApplicationController.h"
31 #include "../../../af/events/ApplicationEvents.h"
32 #include "../../../af/Utils.h"
33 #include "TL4ConverterAction.h"
34 #include "TL4ConverterWizard.h"
35 #include "Plugin.h"
36 
37 // QT
38 #include <QAction>
39 #include <QMenu>
40 #include <QMenuBar>
41 
43  : QObject(), te::core::CppPlugin(pluginInfo),
44  m_showWindow(0)
45 {
46 }
47 
49 {
50 }
51 
53 {
54  if(m_initialized)
55  return;
56 
58 
59  TE_LOG_TRACE(TE_TR("TerraLib Qt TERRALIB4 Plugin startup!"));
60 
61 // add plugin menu
62  //m_terralib4Menu = te::qt::af::AppCtrlSingleton::getInstance().getMenu("Terralib4");
63 
65  evt.m_category = "Terralib4";
66  evt.m_plgName = "Terralib4Converter";
67 
68 
69 // register actions
70  //registerActions();
71  //QMenu* mnu = te::qt::af::AppCtrlSingleton::getInstance().findMenu("Tools");
72  //QAction* act = te::qt::af::AppCtrlSingleton::getInstance().findAction("Tools.Customize");
73 
74  //if(act)
75  //{
76  m_showWindow = new QAction(QIcon::fromTheme("tools-terralib4converter"), "TerraLib 4 Converter...", this);
77  m_showWindow->setObjectName("Tools.TerraLib 4 Converter");
78  evt.m_actions << m_showWindow;
79  //mnu->insertAction(act, m_showWindow);
80  //mnu->addSeparator();
81 
82  connect(m_showWindow, SIGNAL(triggered()), SLOT(showWindow()));
83 
84  emit triggered(&evt);
85  //}
86 
87  //te::qt::af::AddActionToCustomToolbars(&te::qt::af::AppCtrlSingleton::getInstance(), m_showWindow);
88 
89  m_initialized = true;
90 }
91 
93 {
94  if(!m_initialized)
95  return;
96 
97  delete m_showWindow;
98 
99  TE_LOG_TRACE(TE_TR("TerraLib Qt TERRALIB4 Plugin shutdown!"));
100 
101  m_initialized = false;
102 
103  te::qt::af::AppCtrlSingleton::getInstance().removeListener(this);
104 }
105 
107 {
108  QWidget* parent = te::qt::af::AppCtrlSingleton::getInstance().getMainWindow();
110 
111  connect(&dlg, SIGNAL(triggered(te::qt::af::evt::Event*)), SIGNAL(triggered(te::qt::af::evt::Event*)));
112 
113  if(dlg.exec() != QDialog::Accepted)
114  return;
115 }
116 
void triggered(te::qt::af::evt::Event *e)
A base class for application events.
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
Basic information about a plugin.
void shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
URI C++ Library.
Definition: Attributes.h:37
#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...
#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