src/terralib/qt/plugins/timeviewer/Plugin.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled
5  applications.
6 
7  TerraLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License,
10  or (at your option) any later version.
11 
12  TerraLib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with TerraLib. See COPYING. If not, write to
19  TerraLib Team at <terralib-team@terralib.org>.
20 */
21 
22 /*!
23  \file terralib/qt/plugins/timeviewer/plugin.cpp
24 
25  \brief Add a plugin interface for dynamic loading of the TimeViewer plugin.
26 
27  \author Matheus Cavassan Zaglia
28  */
29 
30 // Terralib
31 #include "../../af/ApplicationController.h"
32 
33 // TimeViewer
34 #include "Plugin.h"
35 #include "TimeViewerDockWidget.h"
36 
37 // QT
38 #include <QMenu>
39 
40 #include <iostream>
41 
43  : QObject(nullptr),
44  te::core::CppPlugin(pluginInfo),
45  m_timeViewerAction(nullptr),
46  m_tvDock(nullptr)
47 {
48 }
49 
51 
53 {
54  if(m_initialized)
55  return;
56 
57  m_timeViewerAction = new QAction(this);
58  m_timeViewerAction->setText("Time Viewer");
59  m_timeViewerAction->setObjectName("TimeViewer");
60  m_timeViewerAction->setIcon(QIcon::fromTheme("time-viewer"));
61 
62  connect(m_timeViewerAction, SIGNAL(triggered()), this,SLOT(onTimeViewerActionTriggered()));
63 
64  te::qt::af::AppCtrlSingleton::getInstance().getMenu("Plugins")->addAction(m_timeViewerAction);
65 
66  m_initialized = true;
67 }
68 
70 {
71  if(!m_initialized)
72  return;
73 
74  delete m_tvDock;
75  delete m_timeViewerAction;
76 
77  te::qt::af::AppCtrlSingleton::getInstance().removeListener(this);
78 
79  m_initialized = false;
80 }
81 
83 {
84  if(!m_tvDock){
86  }
87 
88  m_tvDock->show();
89  m_tvDock->raise();
90 }
91 
93 {
94  emit triggered(e);
95 }
96 
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
A base class for application events.
Basic information about a plugin.
void shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
void triggered(te::qt::af::evt::Event *e)
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...
Plugin(const te::core::PluginInfo &pluginInfo)
te::qt::plugins::tv::TimeViewerDockWidget * m_tvDock
Add a plugin interface for dynamic loading of the TimeViewer plugin.