All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ApplicationController.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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/af/ApplicationController.cpp
22 
23  \brief The base API for controllers of TerraLib applications.
24 */
25 
26 // Boost
27 #include <boost/foreach.hpp> // Boost => don't change this include order, otherwise you may have compiling problems!
28 
29 // TerraLib
30 #include "../../common/Exception.h"
31 #include "../../common/PlatformUtils.h"
32 #include "../../common/Translator.h"
33 #include "../../common/TerraLib.h"
34 #include "../../common/SystemApplicationSettings.h"
35 #include "../../common/UserApplicationSettings.h"
36 #include "../../common/Logger.h"
37 #include "../../common/Version.h"
38 #include "../../dataaccess/serialization/xml/Serializer.h"
39 #include "../../plugin/PluginManager.h"
40 #include "../../plugin/PluginInfo.h"
41 #include "../../plugin/Utils.h"
42 #include "../../srs/Config.h"
43 #include "../widgets/help/AssistantHelpManagerImpl.h"
44 #include "../widgets/help/HelpManager.h"
45 #include "../widgets/Utils.h"
46 #include "../widgets/utils/ScopedCursor.h"
48 #include "ApplicationController.h"
49 #include "Exception.h"
50 #include "Project.h"
51 #include "SplashScreenManager.h"
52 #include "Utils.h"
53 #include "XMLFormatter.h"
54 
55 // Qt
56 #include <QApplication>
57 #if QT_VERSION < 0x050000
58 #include <QDesktopServices>
59 #endif
60 #include <QDir>
61 #include <QIcon>
62 #include <QMenu>
63 #include <QMessageBox>
64 #include <QResource>
65 #if QT_VERSION >= 0x050000
66 #include <QStandardPaths>
67 #endif
68 #include <QWidget>
69 
70 // Boost
71 #include <boost/filesystem.hpp>
72 
73 #if defined(TERRALIB_APACHE_LOG4CXX_ENABLED) && defined(TERRALIB_LOGGER_ENABLED)
74 //Log4cxx
75 #include <log4cxx/basicconfigurator.h>
76 #include <log4cxx/consoleappender.h>
77 #include <log4cxx/fileappender.h>
78 #include <log4cxx/helpers/pool.h>
79 #include <log4cxx/helpers/transcoder.h>
80 #include <log4cxx/logger.h>
81 #include <log4cxx/logmanager.h>
82 #include <log4cxx/logstring.h>
83 #include <log4cxx/simplelayout.h>
84 #endif
85 
86 //te::qt::af::ApplicationController* te::qt::af::ApplicationController::sm_instance(0);
87 
89  : QObject(/*parent*/),
90  m_msgBoxParentWidget(0),
91  m_defaultSRID(TE_UNKNOWN_SRS),
92  m_selectionColor(QColor(0, 255, 0)),
93  m_initialized(false),
94  m_project(0),
95  m_resetTerralib(true)
96 {
97 }
98 
100 {
101 
102 }
103 
104 void te::qt::af::ApplicationController::setConfigFile(const std::string& configFileName)
105 {
106  m_appConfigFile = configFileName;
107 }
108 
110 {
111  m_msgBoxParentWidget = w;
112 }
113 
114 void te::qt::af::ApplicationController::addToolBar(const QString& id, QToolBar* bar)
115 {
116  registerToolBar(id, bar);
117 
118 // send event: tool bar added
120 
121  broadcast(&evt);
122 }
123 
124 void te::qt::af::ApplicationController::registerToolBar(const QString& id, QToolBar* bar)
125 {
126  QToolBar* b = getToolBar(id);
127 
128  if(b != 0)
129  throw Exception(TE_TR("There is already a tool bar registered with the same name!"));
130 
131  m_toolbars[id] = bar;
132 }
133 
134 QToolBar* te::qt::af::ApplicationController::getToolBar(const QString& id) const
135 {
136  std::map<QString, QToolBar*>::const_iterator it = m_toolbars.find(id);
137 
138  return (it != m_toolbars.end()) ? it->second : 0;
139 }
140 
142 {
143  std::vector<QToolBar*> res;
144  std::map<QString, QToolBar*>::const_iterator it;
145 
146  for(it = m_toolbars.begin(); it != m_toolbars.end(); ++it)
147  res.push_back(it->second);
148 
149  return res;
150 }
151 
153 {
154  std::map<QString, QToolBar*>::iterator it = m_toolbars.find(id);
155 
156  if(it != m_toolbars.end())
157  m_toolbars.erase(it);
158 }
159 
161 {
162  m_menus.push_back(mnu);
163 }
164 
165 QMenu* te::qt::af::ApplicationController::findMenu(const QString& id) const
166 {
167  std::vector<QMenu*>::const_iterator it;
168 
169  // Searching in menus vector
170  for(it = m_menus.begin(); it != m_menus.end(); ++it)
171  {
172  QMenu* mnu = te::qt::widgets::FindMenu(id, *it);
173 
174  if(mnu != 0)
175  return mnu;
176  }
177 
178  // Searching in menu bars vector
179  std::vector<QMenuBar*>::const_iterator it_bar;
180 
181  for(it_bar = m_menuBars.begin(); it_bar != m_menuBars.end(); ++it_bar)
182  {
183  QMenu* mnu = te::qt::widgets::FindMenu(id, *it_bar);
184 
185  if(mnu != 0)
186  return mnu;
187  }
188 
189  return 0;
190 }
191 
193 {
194  QMenu* mnu = findMenu(id);
195 
196  if(mnu == 0)
197  {
198  if(!m_menuBars.empty())
199  mnu = te::qt::widgets::GetMenu(id, m_menuBars[0]);
200  else
201  {
202  mnu = new QMenu(id);
203  m_menus.push_back(mnu);
204  }
205  }
206 
207  return mnu;
208 }
209 
211 {
212  m_menuBars.push_back(bar);
213 }
214 
215 QMenuBar* te::qt::af::ApplicationController::findMenuBar(const QString& id) const
216 {
217  throw Exception("Not implemented yet.");
218 }
219 
220 QMenuBar* te::qt::af::ApplicationController::getMenuBar(const QString& id) const
221 {
222  return m_menuBars[0];
223 }
224 
225 QAction* te::qt::af::ApplicationController::findAction(const QString& id) const
226 {
227  for(size_t i=0; i<m_menus.size(); i++)
228  {
229  QAction* act = te::qt::widgets::FindAction(id, m_menus[i]);
230 
231  if (act != 0)
232  return act;
233  }
234 
235  for(size_t i=0; i<m_menuBars.size(); i++)
236  {
237  QAction* act = te::qt::widgets::FindAction(id, m_menuBars[i]);
238 
239  if (act != 0)
240  return act;
241  }
242 
243  return 0;
244 }
245 
247 {
248  std::set<QObject*>::const_iterator it = m_applicationItems.find(obj);
249 
250  if(it != m_applicationItems.end())
251  return;
252 
253  m_applicationItems.insert(obj);
254 
255  obj->connect(this, SIGNAL(triggered(te::qt::af::evt::Event*)), SLOT(onApplicationTriggered(te::qt::af::evt::Event*)));
256 }
257 
259 {
260  std::set<QObject*>::iterator it = m_applicationItems.find(obj);
261 
262  if(it == m_applicationItems.end())
263  return;
264 
265  m_applicationItems.erase(it);
266 
267  disconnect(SIGNAL(triggered(te::qt::af::evt::Event*)), obj, SLOT(onApplicationTriggered(te::qt::af::evt::Event*)));
268 }
269 
271 {
272  if(m_initialized)
273  return;
274 
275 // find user data directory
276 #if QT_VERSION >= 0x050000
277  m_userDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
278 #else
279  m_userDataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
280 #endif
281 
282  if(!boost::filesystem::exists(m_userDataDir.toStdString()))
283  boost::filesystem::create_directories(m_userDataDir.toStdString());
284 
285  te::qt::widgets::ScopedCursor cursor(Qt::WaitCursor);
286 
287  SplashScreenManager::getInstance().showMessage(tr("Loading TerraLib Modules..."));
288 
289 // terralib log startup
290 #if defined(TERRALIB_APACHE_LOG4CXX_ENABLED) && defined(TERRALIB_LOGGER_ENABLED)
291  std::string path = m_userDataDir.toStdString();
292  path += "/log/terralib.log";
293 
294  log4cxx::FileAppender* fileAppender = new log4cxx::FileAppender(log4cxx::LayoutPtr(new log4cxx::SimpleLayout()),
295  log4cxx::helpers::Transcoder::decode(path.c_str()), false);
296 
297  log4cxx::helpers::Pool p;
298  fileAppender->activateOptions(p);
299 
300  log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(fileAppender));
301  log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getAll() /*log4cxx::Level::getDebug()*/);
302  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("te");
303 #endif
304  //LOG4CXX_INFO(logger, "Created FileAppender appender");
305 
306  if(m_resetTerralib)
308 
309  SplashScreenManager::getInstance().showMessage(tr("TerraLib Modules loaded!"));
310 
311  SplashScreenManager::getInstance().showMessage(tr("Loading the application configuration file..."));
312 
314 
315 // general application info
316  SplashScreenManager::getInstance().showMessage(tr("Application configuration file loaded!"));
317 
318  m_appName = QString::fromStdString(te::common::SystemApplicationSettings::getInstance().getValue("Application.Name"));
319  m_appTitle = QString::fromStdString(te::common::SystemApplicationSettings::getInstance().getValue("Application.Title"));
320  m_appIconName = QString::fromStdString(te::common::SystemApplicationSettings::getInstance().getValue("Application.IconName"));
321 
322  if(!boost::filesystem::exists(m_appIconName.toStdString()))
323  m_appIconName = te::common::FindInTerraLibPath(m_appIconName.toStdString()).c_str();
324 
325  m_aboutLogo = QString::fromStdString(te::common::SystemApplicationSettings::getInstance().getValue("Application.AboutDialogLogo.<xmlattr>.xlink:href"));
326 
327  if(!boost::filesystem::exists(m_aboutLogo.toStdString()))
328  m_aboutLogo = te::common::FindInTerraLibPath(m_aboutLogo.toStdString()).c_str();
329 
330  m_tLibLogo = QString::fromStdString(te::common::SystemApplicationSettings::getInstance().getValue("Application.TerraLibLogo.<xmlattr>.xlink:href"));
331 
332  if(!boost::filesystem::exists(m_tLibLogo.toStdString()))
333  m_tLibLogo = te::common::FindInTerraLibPath(m_tLibLogo.toStdString()).c_str();
334 
335  QString fullAppName = m_appName + "-" + QString(te::common::Version::asString().c_str());
336  qApp->setApplicationName(fullAppName);
337 
338  m_appOrganization = QString::fromStdString(te::common::SystemApplicationSettings::getInstance().getValue("Application.Organization"));
339 
340  qApp->setOrganizationName(m_appOrganization);
341 
342 // load help system
343  try
344  {
345  std::string help_file = te::common::FindInTerraLibPath(te::common::SystemApplicationSettings::getInstance().getValue("Application.HelpFile.<xmlattr>.xlink:href"));
346 
347  m_appHelpFile = QString::fromStdString(help_file);
348 
349  QFileInfo info(m_appHelpFile);
350 
351  if(!m_appHelpFile.isEmpty() && info.exists())
352  {
353  SplashScreenManager::getInstance().showMessage(tr("Loading application help system..."));
354 
356 
357  te::qt::widgets::HelpManager::getInstance().setImpl(helpImpl);
358 
359  SplashScreenManager::getInstance().showMessage(tr("Application help system loaded!"));
360  }
361  }
362  catch(const std::exception& e)
363  {
364  te::qt::widgets::ScopedCursor acursor(Qt::ArrowCursor);
365 
366  QString msgErr(tr("Error loading application help system: %1"));
367 
368  msgErr = msgErr.arg(e.what());
369 
370  QMessageBox::warning(m_msgBoxParentWidget, m_appTitle, msgErr);
371  }
372 
373 // hold user settings
374  QSettings user_settings(QSettings::IniFormat,
375  QSettings::UserScope,
376  QApplication::instance()->organizationName(),
377  QApplication::instance()->applicationName());
378 
379 // load icon theme
380  try
381  {
382  SplashScreenManager::getInstance().showMessage(tr("Loading application icon theme..."));
383 
384  std::string icon_dir = te::common::FindInTerraLibPath(te::common::SystemApplicationSettings::getInstance().getValue("Application.IconThemeInfo.BaseDirectory.<xmlattr>.xlink:href"));
385 
386  m_appIconThemeDir = QString::fromStdString(icon_dir);
387 
388  if(!m_appIconThemeDir.isEmpty())
389  {
390  QStringList ithemes = QIcon::themeSearchPaths();
391 
392  ithemes.push_back(m_appIconThemeDir);
393 
394  QIcon::setThemeSearchPaths(ithemes);
395  }
396 
397  m_appDefaultIconTheme = QString::fromStdString(te::common::SystemApplicationSettings::getInstance().getValue("Application.IconThemeInfo.DefaultTheme"));
398 
399  QVariant iconTheme = user_settings.value("icon_theme/selected_theme", m_appDefaultIconTheme);
400 
401  QIcon::setThemeName(iconTheme.toString());
402 
403  QVariant iconSize = user_settings.value("toolbars/icon_size", te::common::SystemApplicationSettings::getInstance().getValue("Application.ToolBarDefaultIconSize").c_str());
404 
405  {
406  QString sh = QString("QToolBar { qproperty-iconSize: ") + iconSize.toString() + "px " + iconSize.toString() + "px; }";
407  qApp->setStyleSheet(sh);
408  }
409 
410 // Default SRID
411  QVariant srid = user_settings.value("srs/default_srid", te::common::SystemApplicationSettings::getInstance().getValue("Application.DefaultSRID").c_str());
412 
413  m_defaultSRID = srid.toInt();
414 
415 // Selection Color
416  QVariant selectionColor = user_settings.value("color/selection_color", te::common::SystemApplicationSettings::getInstance().getValue("Application.DefaultSelectionColor").c_str());
417 
418  m_selectionColor = QColor(selectionColor.toString());
419 
420  SplashScreenManager::getInstance().showMessage(tr("Application icon theme loaded!"));
421  }
422  catch(const std::exception& e)
423  {
424  te::qt::widgets::ScopedCursor acursor(Qt::ArrowCursor);
425 
426  QString msgErr(tr("Error loading application icon theme: %1"));
427 
428  msgErr = msgErr.arg(e.what());
429 
430  QMessageBox::warning(m_msgBoxParentWidget, m_appTitle, msgErr);
431  }
432 
433 // load registered data sources
434  try
435  {
436  m_appDatasourcesFile = user_settings.value("data_sources/data_file", "").toString().toStdString();
437 
438  if(!m_appDatasourcesFile.empty())
439  {
440  SplashScreenManager::getInstance().showMessage(tr("Loading user registered data sources..."));
441 
442  te::serialize::xml::ReadDataSourceInfo(m_appDatasourcesFile);
443 
445 
446  SplashScreenManager::getInstance().showMessage(tr("Known data sources loaded!"));
447  }
448  }
449  catch(const std::exception& e)
450  {
451  te::qt::widgets::ScopedCursor acursor(Qt::ArrowCursor);
452 
453  QString msgErr(tr("Error loading the registered data sources: %1"));
454 
455  msgErr = msgErr.arg(e.what());
456 
457  QMessageBox::warning(m_msgBoxParentWidget, m_appTitle, msgErr);
458  }
459 
460  QFileInfo info(user_settings.fileName());
461 
462  if(!info.exists())
464 
465  m_initialized = true;
466 }
467 
469 {
470  te::qt::widgets::ScopedCursor cursor(Qt::WaitCursor);
471 
472  std::vector<std::string> plgFiles;
473 
474  try
475  {
476  SplashScreenManager::getInstance().showMessage(tr("Reading application plugins list..."));
477 
478  plgFiles = GetPluginsFiles();
479 
480  //SplashScreenManager::getInstance().showMessage(tr("Plugins list read!"));
481 
482  SplashScreenManager::getInstance().showMessage(tr("Checking enabled plugins..."));
483 
484  QSettings user_settings(QSettings::IniFormat,
485  QSettings::UserScope,
486  QApplication::instance()->organizationName(),
487  QApplication::instance()->applicationName());
488 
489  user_settings.beginGroup("plugins");
490 
491  std::set<std::string> user_enabled_plugins;
492 
493  int nitems = user_settings.beginReadArray("enabled");
494 
495  for(int i = 0; i != nitems; ++i)
496  {
497  user_settings.setArrayIndex(i);
498 
499  QString name = user_settings.value("name").toString();
500 
501  user_enabled_plugins.insert(name.toStdString());
502  }
503 
504  user_settings.endArray();
505 
506  user_settings.endGroup();
507 
508  //SplashScreenManager::getInstance().showMessage(tr("Enabled plugin list read!"));
509 
510  SplashScreenManager::getInstance().showMessage(tr("Loading plugins..."));
511 
512 // retrieve information for each plugin
513  boost::ptr_vector<te::plugin::PluginInfo> plugins;
514 
515  for(std::size_t i = 0; i != plgFiles.size(); ++i)
516  {
518 
519  if(user_enabled_plugins.empty()) // if there is no list of enabled plugins
520  plugins.push_back(pinfo); // try to load all!
521  else if(user_enabled_plugins.count(pinfo->m_name) != 0) // else, if a list is available,
522  plugins.push_back(pinfo); // load only enabled plugins
523  else // otherwise
524  delete pinfo; // release plugin info
525  }
526 
527 // load and start each plugin
529 
530  SplashScreenManager::getInstance().showMessage(tr("Plugins loaded successfully!"));
531  }
532  catch(const std::exception& e)
533  {
534  te::qt::widgets::ScopedCursor acursor(Qt::ArrowCursor);
535 
536  QString msgErr(tr("Error reading application's plugin list: %1"));
537 
538  msgErr = msgErr.arg(e.what());
539 
540  QMessageBox::warning(m_msgBoxParentWidget, m_appTitle, msgErr);
541  }
542 }
543 
545 {
546  SplashScreenManager::getInstance().showMessage("Loading recent projects...");
547 
548  try
549  {
550  QSettings user_settings(QSettings::IniFormat,
551  QSettings::UserScope,
552  QApplication::instance()->organizationName(),
553  QApplication::instance()->applicationName());
554 
555  QVariant projPath = user_settings.value("projects/most_recent/path", "");
556  QVariant projTitle = user_settings.value("projects/most_recent/title", "");
557 
558  QMenu* mnu = getMenu("File.Recent Projects");
559 
560  if(!projPath.toString().isEmpty())
561  {
562  QAction* act = mnu->addAction(projPath.toString());
563  act->setData(projPath);
564 
565  mnu->addSeparator();
566 
567  m_recentProjs.append(projPath.toString());
568  m_recentProjsTitles.append(projTitle.toString());
569  }
570 
571  user_settings.beginGroup("projects");
572 
573  int nrc = user_settings.beginReadArray("recents");
574 
575  for(int i = 0; i != nrc; ++i)
576  {
577  user_settings.setArrayIndex(i);
578  QString npath = user_settings.value("projects/path").toString();
579  QString ntitle = user_settings.value("projects/title").toString();
580 
581 
582  QAction* act = mnu->addAction(npath);
583  act->setData(npath);
584  m_recentProjs.append(npath);
585  m_recentProjsTitles.append(ntitle);
586  }
587 
588  mnu->setEnabled(true);
589 
590  SplashScreenManager::getInstance().showMessage("Recent projects loaded!");
591  }
592  catch(const std::exception& e)
593  {
594  te::qt::widgets::ScopedCursor acursor(Qt::ArrowCursor);
595 
596  QString msgErr(tr("Error loading the registered projects: %1"));
597 
598  msgErr = msgErr.arg(e.what());
599 
600  QMessageBox::warning(m_msgBoxParentWidget, m_appTitle, msgErr);
601  }
602 }
603 
604 void te::qt::af::ApplicationController::updateRecentProjects(const QString& prjFile, const QString& prjTitle)
605 {
606  int pos = m_recentProjs.indexOf(prjFile);
607 
608  QString author;
609  int maxSaved;
610 
611  GetProjectInformationsFromSettings(author, maxSaved);
612 
613  if(pos != 0)
614  {
615  if(pos < 0)
616  {
617  if(m_recentProjs.size() > maxSaved) // TODO: Size of the list must be configurable.
618  {
619  m_recentProjs.removeLast();
620  m_recentProjsTitles.removeLast();
621  }
622 
623  m_recentProjs.prepend(prjFile);
624  m_recentProjsTitles.prepend(prjTitle);
625  }
626  else
627  {
628  m_recentProjs.move(pos, 0);
629  m_recentProjsTitles.move(pos, 0);
630  }
631 
632  if(m_recentProjs.isEmpty())
633  return;
634 
635  QMenu* mnu = getMenu("File.Recent Projects");
636 
637  mnu->clear();
638 
639  mnu->setEnabled(true);
640 
641  QString recPrj = m_recentProjs.at(0);
642  QAction* act = mnu->addAction(recPrj);
643  act->setData(recPrj);
644 
645  mnu->addSeparator();
646 
647  if(m_recentProjs.size() > 1)
648  for(int i=1; i<m_recentProjs.size(); i++)
649  {
650  recPrj = m_recentProjs.at(i);
651  act = mnu->addAction(recPrj);
652  act->setData(recPrj);
653  }
654  }
655 
656  QAction* act = findAction("File.Save Project As");
657 
658  if(act != 0)
659  act->setEnabled(true);
660 }
661 
663 {
664  m_project = prj;
665 }
666 
668 {
669  return m_project;
670 }
671 
673 {
674  if(!m_initialized)
675  return;
676 
677  UpdateUserSettings(m_recentProjs, m_recentProjsTitles, m_appUserSettingsFile);
678 
680 
682 
684 
686 
687  if(m_resetTerralib)
689 
690  m_appConfigFile.clear();
691 
692  m_applicationItems.clear();
693 
694  m_menuBars.clear();
695 
696  m_menus.clear();
697 
698  m_toolbars.clear();
699 
700  m_aboutLogo.clear();
701 
702  m_appDatasourcesFile.clear();
703 
704  m_appDefaultIconTheme.clear();
705 
706  m_appHelpFile.clear();
707 
708  m_appIconName.clear();
709 
710  m_appIconThemeDir.clear();
711 
712  m_appName.clear();
713 
714  m_msgBoxParentWidget = 0;
715 
716  m_appOrganization.clear();
717 
718  m_appTitle.clear();
719 
720  m_tLibLogo.clear();
721 
722  m_recentProjs.clear();
723 
724  m_recentProjsTitles.clear();
725 
726  m_appUserSettingsFile.clear();
727 
728  m_appPluginsFile.clear();
729 
730  m_appToolBarDefaultIconSize.clear();
731 
732  m_defaultSRID = 0;
733 
734  m_selectionColor = QColor();
735 
736  m_project = 0;
737 
738  m_initialized = false;
739 }
740 
742 {
743  return m_appSettings;
744 }
745 
747 {
748  // Need to check event send to prevent loops
749  // -----------------------------------------
750 
751  emit triggered(evt);
752 }
753 
755 {
756  return m_appTitle;
757 }
758 
760 {
761  return m_appIconName;
762 }
763 
765 {
766  return m_aboutLogo;
767 }
768 
770 {
771  return m_tLibLogo;
772 }
773 
775 {
776  return m_recentProjs.isEmpty() ? QString("") : m_recentProjs.front();
777 }
778 
780 {
781  return m_defaultSRID;
782 }
783 
785 {
786  return m_selectionColor;
787 }
788 
790 {
791  m_selectionColor = c;
792 }
793 
795 {
796  return m_msgBoxParentWidget;
797 }
798 
800 {
801  m_resetTerralib = status;
802 }
803 
805 {
806  return m_userDataDir;
807 }
TEQTAFEXPORT std::vector< std::string > GetPluginsFiles()
Definition: Utils.cpp:661
virtual void setConfigFile(const std::string &configFileName)
It gives access to the controller singleton.
void registerMenu(QMenu *mnu)
Register the mnu.
std::string m_name
The plugin name: an internal value used to identify the plugin in the system. Must be a unique value...
Definition: PluginInfo.h:66
TEQTWIDGETSEXPORT QAction * FindAction(const QString &actText, QMenu *mnu)
Definition: Utils.cpp:131
TEQTAFEXPORT void CreateDefaultSettings()
Creates a default QSettings.
Definition: Utils.cpp:488
virtual void initializePlugins()
Load the plugin list and initialize the plugins enabled by the user.
const QString & getAppTitle() const
Returns the application title.
TECOMMONEXPORT std::string FindInTerraLibPath(const std::string &p)
Returns the path relative to a directory or file in the context of TerraLib.
QMenu * getMenu(const QString &id)
Returns a menu registered with key id.
A base class for application events.
Definition: Event.h:59
QWidget * getMainWindow() const
Returns main window.
void registerMenuBar(QMenuBar *bar)
Register the bar.
const QString & getAppIconName() const
Returns the application icon.
static std::string asString()
Definition: Version.cpp:60
This class models the concept of a project for the TerraLib Application Framework.
void setResetTerraLibFlag(const bool &status)
A singleton for holding he application splash screen.
void set(te::qt::af::Project *prj)
Set the current project.
QMenuBar * getMenuBar(const QString &id) const
Returns a menu bar registered with key id.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:345
TEQTAFEXPORT void UpdateUserSettings(const QStringList &prjFiles, const QStringList &prjTitles, const std::string &userConfigFile)
Updates user settings file section about information of the projects.
Definition: Utils.cpp:222
void showMessage(const QString &message)
This will cause the text to be drawn on the splash screen and a call to Application::processEvents() ...
TEQTAFEXPORT void SaveDataSourcesFile()
Saves data sources file.
Definition: Utils.cpp:280
QToolBar * getToolBar(const QString &id) const
Return the toolbar identified by id or NULL if none is found.
virtual void initialize()
Initializes the application framework.
QMenu * findMenu(const QString &id) const
Returns the menu registered with key id.
QColor getSelectionColor() const
Returns the application selection color.
void finalize()
It finalizes the TerraLib Platform.
Definition: TerraLib.cpp:64
static SplashScreenManager & getInstance()
It returns a reference to the singleton instance.
void removeToolBar(const QString &id)
Removes the toolbar identified by id.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:44
void addListener(QObject *obj)
Insert an application item that will listen to framework events.
TEQTAFEXPORT void GetProjectInformationsFromSettings(QString &defaultAuthor, int &maxSaved)
Definition: Utils.cpp:434
virtual void setMsgBoxParentWidget(QWidget *w)
Tells the widget to be used as the parent of messages showned in a QMessageBox.
virtual void initializeProjectMenus()
Initializes the menus for the most recent open projects.
Utility functions for dealing with plugins.
void addToolBar(const QString &id, QToolBar *bar)
Register the toolbar in the list of the known toolbars and dispatch an event.
void initialize()
It initializes the TerraLib Platform.
Definition: TerraLib.cpp:33
QSettings & getSettings()
Return the QSettings of the application. This can be used to add settings from external sources...
void broadcast(te::qt::af::evt::Event *evt)
Send events in broadcast for all registered components.
bool decode(std::string &s)
Decode the pct-encoded (hex) sequences, if any, return success.
Definition: urisyn.cpp:171
void setSelectionColor(const QColor &c)
Sets the application selection color.
te::qt::af::Project * getProject()
Get the current project.
QMenuBar * findMenuBar(const QString &id) const
Returns the menu bar registered with key id.
TEQTWIDGETSEXPORT QMenu * FindMenu(const QString &mnuText, QMenu *mnu)
Finds a menu item in the mnu object.
Definition: Utils.cpp:121
This class models the concept of a project for the TerraLib Application Framework.
Definition: Project.h:50
QAction * findAction(const QString &id) const
Returns the action identified by id or NULL if there's not an action identified by id...
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
void removeListener(QObject *obj)
Remove the obj from the list of event listeners.
std::vector< QToolBar * > getToolBars() const
Return the list of registered toolbars.
This event signals that a new toolbar was added.
TEQTWIDGETSEXPORT QMenu * GetMenu(const QString &mnuText, QMenu *mnu)
Gets a menu or submenu contained in the mnu object.
Definition: Utils.cpp:176
The basic information about a plugin.
Definition: PluginInfo.h:61
A class for xml serialization formatting strings.
QString getMostRecentProject() const
Returns the most recent project.
Contains the list of the application events.
TEPLUGINEXPORT PluginInfo * GetInstalledPlugin(const std::string &pluginFilePath)
It returns information about a given plugin provided its plugin configuration file name or dir...
Definition: Utils.cpp:80
static void formatDataSourceInfos(const bool &encode)
Formats all data source informations registered in the te::da::DataSourceInfoManager object...
The base API for controllers of TerraLib applications.
void registerToolBar(const QString &id, QToolBar *bar)
Register the toolbar in the list of the known toolbars.
virtual void finalize()
Finalize the application framework.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
A help manager that uses the QAssistant to manage help files.
TEDATAACCESSEXPORT void ReadDataSourceInfo(const std::string &datasourcesFileName)
Definition: Serializer.cpp:86
void updateRecentProjects(const QString &prjFile, const QString &prjTitle)
Update the list of recent projects. This is commonly used when there's a new most recent project...
int getDefaultSRID() const
Returns the application default SRID value.