src/terralib/qt/af/Utils.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/af/Utils.cpp
22 
23  \brief Utility routines for the TerraLib Application Framework module.
24 */
25 
26 // Boost
27 
28 // TerraLib
29 #include "../../common/BoostUtils.h"
30 #include "../../common/StringUtils.h"
31 #include "../../common/SystemApplicationSettings.h"
32 #include "../../common/UserApplicationSettings.h"
33 #include "../../core/utils/Platform.h"
34 #include "../../dataaccess/datasource/DataSourceInfo.h"
35 #include "../../dataaccess/datasource/DataSourceInfoManager.h"
36 #include "../../dataaccess/serialization/xml/Serializer.h"
37 #include "../../maptools/AbstractLayer.h"
38 #include "../../core/plugin/PluginManager.h"
39 #include "../../maptools/serialization/xml/Layer.h"
40 #include "../../xml/AbstractWriter.h"
41 #include "../../xml/AbstractWriterFactory.h"
42 #include "../../xml/Reader.h"
43 #include "../../xml/ReaderFactory.h"
44 #include "../../Version.h"
45 #include "ApplicationController.h"
46 #include "Exception.h"
47 //#include "Project.h"
48 #include "Utils.h"
49 #include "XMLFormatter.h"
50 
51 // STL
52 #include <cassert>
53 #include <fstream>
54 #include <memory>
55 
56 // Boost
57 #include <boost/property_tree/ptree.hpp>
58 #include <boost/property_tree/json_parser.hpp>
59 #include <boost/algorithm/string/replace.hpp>
60 #include <boost/filesystem.hpp>
61 #include <boost/format.hpp>
62 
63 // Qt
64 #include <QDir>
65 #include <QFileInfo>
66 #include <QSettings>
67 #include <QString>
68 #include <QTextStream>
69 #include <QApplication>
70 #include <QAction>
71 #include <QMainWindow>
72 #include <QMessageBox>
73 #include <QToolBar>
74 #include <QDesktopWidget>
75 
77 {
78  QSettings user_settings(QSettings::IniFormat,
79  QSettings::UserScope,
80  QApplication::instance()->organizationName(),
81  QApplication::instance()->applicationName());
82 
83 // save enabled plugins
84  user_settings.remove("plugins/enabled");
85 
86  user_settings.beginGroup("plugins");
87  user_settings.remove("loaded");
88  user_settings.remove("unloaded");
89 
90  user_settings.beginWriteArray("loaded");
91 
92  int aidx = 0;
93  std::vector<te::core::PluginInfo> loaded =
95 
96  for(std::size_t i = 0; i != loaded.size(); ++i)
97  {
98  user_settings.setArrayIndex(aidx++);
99 
100  user_settings.setValue("name", loaded[i].name.c_str());
101  }
102 
103  user_settings.endArray();
104 
105  // save unloaded plugins
106 
107  std::vector<te::core::PluginInfo> unloaded =
109 
110  user_settings.beginWriteArray("unloaded");
111 
112  int unloadedidx = 0;
113 
114  for(std::size_t i = 0; i != unloaded.size(); ++i)
115  {
116  user_settings.setArrayIndex(unloadedidx++);
117 
118  user_settings.setValue("name", unloaded[i].name.c_str());
119  }
120 
121  std::vector<te::core::PluginInfo> broken =
123 
124  for(std::size_t i = 0; i != broken.size(); ++i)
125  {
126  user_settings.setArrayIndex(unloadedidx++);
127 
128  user_settings.setValue("name", broken[i].name.c_str());
129  }
130 
131  user_settings.endArray();
132 
133  user_settings.endGroup();
134 }
135 
137 {
138  QSettings usettings(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
139 
140  QString fileName = usettings.value("data_sources/data_file").toString();
141 
142  if(fileName.isNull())
143  {
144  const QString& udir = appController->getUserDataDir();
145 
146  fileName = udir + "/" + QString(TERRALIB_APPLICATION_DATASOURCE_FILE_NAME);
147 
148  usettings.setValue("data_sources/data_file", QVariant(fileName));
149  }
150 
151  QFileInfo info(fileName);
152 
153  QDir d = info.absoluteDir();
154 
155  if(!d.exists())
156  d.mkpath(d.path());
157 
159 
160  te::serialize::xml::Save(fileName.toUtf8().data());
161 
163 }
164 
165 
166 void AddToolbarAndActions(QToolBar* bar, QSettings& sett)
167 {
168  sett.beginGroup(bar->objectName());
169 
170  sett.setValue("name", bar->objectName());
171 
172  sett.beginWriteArray("Actions");
173 
174  QList<QAction*> acts = bar->actions();
175 
176  for(int i=0; i<acts.size(); i++)
177  {
178  sett.setArrayIndex(i);
179  sett.setValue("action", acts.at(i)->objectName());
180  }
181 
182  sett.endArray();
183 
184  sett.endGroup();
185 }
186 
188 {
189  std::vector<QToolBar*> bars = appController->getToolBars();
190  std::vector<QToolBar*>::const_iterator it;
191  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
192 
193  sett.beginGroup("toolbars");
194 
195  for (it = bars.begin(); it != bars.end(); ++it)
196  {
197  QToolBar* bar = *it;
198 
199  sett.remove(bar->objectName());
200 
201  AddToolbarAndActions(bar, sett);
202  }
203 
204  sett.endGroup();
205 }
206 
208 {
209  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
210 
211  sett.beginGroup("toolbars");
212 
213  AddToolbarAndActions(bar, sett);
214 
215  sett.endGroup();
216 }
217 
219 {
220  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
221 
222  sett.beginGroup("toolbars");
223  sett.remove(bar->objectName());
224  sett.endGroup();
225 }
226 
227 std::vector<QToolBar*> te::qt::af::ReadToolBarsFromSettings(te::qt::af::ApplicationController* appController, QWidget* barsParent)
228 {
229  std::vector<QToolBar*> bars;
230 
231  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
232 
233  sett.beginGroup("toolbars");
234  QStringList lst = sett.childGroups();
235 
236  QStringList::iterator it;
237 
238  for(it=lst.begin(); it != lst.end(); ++it)
239  {
240  QString gr = *it;
241 
242  sett.beginGroup(gr);
243 
244  QString grName = sett.value("name").toString();
245 
246  int size = sett.beginReadArray("Actions");
247 
248  QToolBar* toolbar = new QToolBar(barsParent);
249  toolbar->setObjectName(grName);
250  toolbar->setWindowTitle(grName);
251 
252  for(int i=0; i<size; i++)
253  {
254  sett.setArrayIndex(i);
255  QString act = sett.value("action").toString();
256 
257  if(act == "")
258  {
259  toolbar->addSeparator();
260  }
261  else
262  {
263  QAction* a = appController->findAction(act);
264 
265  if(a != nullptr)
266  toolbar->addAction(a);
267  }
268  }
269 
270  sett.endArray();
271  sett.endGroup();
272 
273  bars.push_back(toolbar);
274  }
275 
276  sett.endGroup();
277 
278  return bars;
279 }
280 
282 {
283  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
284 
285  sett.beginGroup("mainWindow");
286  sett.setValue("geometry", mainWindow->saveGeometry());
287  sett.setValue("windowState", mainWindow->saveState());
288  sett.endGroup();
289 }
290 
292 {
293  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
294 
295  sett.beginGroup("mainWindow");
296  mainWindow->restoreGeometry(sett.value("geometry").toByteArray());
297  mainWindow->restoreState(sett.value("windowState").toByteArray());
298  sett.endGroup();
299 }
300 
301 //void te::qt::af::GetProjectInformationsFromSettings(QString& defaultAuthor, int& maxSaved)
302 //{
303 // QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
304 //
305 // sett.beginGroup("projects");
306 // defaultAuthor = sett.value("author_name").toString();
307 // maxSaved = sett.value("recents_history_size").toInt();
308 // sett.endGroup();
309 //}
310 
311 //void te::qt::af::SaveProjectInformationsOnSettings(const QString& defaultAuthor, const int& maxSaved)
312 //{
313 // QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
314 //
315 // sett.beginGroup("projects");
316 // sett.setValue("author_name", defaultAuthor);
317 // sett.setValue("recents_history_size", maxSaved);
318 // sett.endGroup();
319 //}
320 
321 void te::qt::af::SaveLastDatasourceOnSettings(const QString& dsType)
322 {
323  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
324 
325  sett.setValue("projects/last datasource used", dsType);
326 }
327 
328 //void te::qt::af::SaveOpenLastProjectOnSettings(bool openLast)
329 //{
330 // QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
331 //
332 // sett.setValue("projects/openLastDataSource", openLast);
333 //}
334 
336 {
337  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
338 
339  return sett.value("projects/last datasource used").toString();
340 }
341 
342 //bool te::qt::af::GetOpenLastProjectFromSettings()
343 //{
344 // QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
345 //
346 // QVariant variant = sett.value("projects/openLastDataSource");
347 //
348 // // If the option was never edited
349 // if(variant.isNull() || !variant.isValid())
350 // return true;
351 //
352 // return variant.toBool();
353 //}
354 
355 QString te::qt::af::UnsavedStar(const QString windowTitle, bool isUnsaved)
356 {
357  QString result(windowTitle);
358 
359  if(isUnsaved)
360  {
361  if(result.at(result.count()-1) != '*')
362  result += "*";
363  }
364  else
365  {
366  if(result.at(result.count()-1) == '*')
367  result.remove((result.count()-1), 1);
368  }
369 
370  return result;
371 }
372 
374 {
375  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
376  QString hexColor = sett.value("display/defaultDisplayColor").toString();
377  QColor defaultColor;
378  defaultColor.setNamedColor(hexColor);
379  if(!defaultColor.isValid())
380  return Qt::white;
381 
382  return defaultColor;
383 }
384 
385 QString te::qt::af::GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
386 {
387  QString sty("alternate-background-color: ");
388  sty += "rgb(" + QString::number(secondaryColor.red()) + ", " + QString::number(secondaryColor.green());
389  sty += ", " + QString::number(secondaryColor.blue()) + ")";
390  sty += ";background-color: rgb(" + QString::number(primaryColor.red()) + ", " + QString::number(primaryColor.green());
391  sty += ", " + QString::number(primaryColor.blue()) + ");";
392 
393  return sty;
394 }
395 
397 {
398  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
399  //bool isChecked = sett.value("table/tableAlternateColors").toBool();
400  QColor pColor;
401  pColor.setNamedColor(sett.value("table/primaryColor").toString());
402  QColor sColor;
403  sColor.setNamedColor(sett.value("table/secondaryColor").toString());
404 
405  if(!pColor.isValid())
406  pColor = Qt::white;
407  if(!sColor.isValid())
408  sColor = Qt::white;
409 
410  return GetStyleSheetFromColors(pColor, sColor);
411 }
412 
414 {
415  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
416  bool isChecked = sett.value("table/tableAlternateColors").toBool();
417 
418  return isChecked;
419 }
420 
422 {
423  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
424 
425  sett.beginGroup("toolbars");
426  QStringList lst = sett.childGroups();
427  QStringList::iterator it;
428 
429  for(it=lst.begin(); it!=lst.end(); ++it)
430  {
431  int size = sett.beginReadArray(*it+"/Actions");
432 
433  for(int i=0; i<size; i++)
434  {
435  sett.setArrayIndex(i);
436 
437  QString v = sett.value("action").toString();
438 
439  if (!v.isNull() && v.compare(act->objectName()) == 0)
440  {
441  QToolBar* bar = appController->getToolBar(*it);
442  bar->addAction(act);
443 
444  break;
445  }
446  }
447 
448  sett.endArray();
449  }
450 
451  sett.endGroup();
452 }
453 
454 std::vector<std::string> te::qt::af::GetPluginsFiles()
455 {
456  std::vector<std::string> res;
457 
458  QStringList filters;
459 
460  filters << "*.teplg.json";
461 
462  QDir d(te::core::FindInTerraLibPath("share/terralib/plugins").c_str());
463 
464  QFileInfoList files = d.entryInfoList(filters, QDir::Files);
465 
466  foreach(QFileInfo file, files)
467  {
468  res.push_back(file.absoluteFilePath().toUtf8().data());
469  }
470 
471  return res;
472 }
473 
475 {
476  std::vector<std::string> res;
477 
478 // Finding the Default plugins file.
479  std::string pluginsPath = appController->getAppPluginsPath().toUtf8().data();
480 
481  if (pluginsPath == "")
482  return res;
483 
484 // Reading JSON
485  boost::property_tree::ptree pt;
486  boost::property_tree::json_parser::read_json(pluginsPath, pt);
487 
488  for(boost::property_tree::ptree::value_type &v: pt.get_child("plugins"))
489  {
490  res.push_back(v.second.get<std::string>("plugin"));
491  }
492 
493  return res;
494 }
495 
496 std::vector<std::string> te::qt::af::GetPluginsNames(const std::vector<std::string>& plgFiles)
497 {
498  std::vector<std::string> res;
499  std::vector<std::string>::const_iterator it;
500 
501  for(it=plgFiles.begin(); it!=plgFiles.end(); ++it)
502  {
503  boost::property_tree::ptree p;
504  boost::property_tree::read_xml(*it, p, boost::property_tree::xml_parser::trim_whitespace);
505 
506  res.push_back(p.get<std::string>("PluginInfo.Name"));
507  }
508 
509  return res;
510 }
511 
513 {
514  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
515 
516  return sett.value("configuration/generation").toString();
517 }
518 
519 void te::qt::af::SetDateTime(const QString& dateTime)
520 {
521  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
522 
523  sett.setValue("configuration/generation", dateTime);
524 }
525 
527 {
528  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
529 
530  QFileInfo info(sett.fileName());
531 
532  return info.absolutePath();
533 }
534 
535 void te::qt::af::UpdateUserSettingsFile(const QString& fileName, const bool& removeOlder)
536 {
537  QFileInfo info(fileName);
540 
541  if(info.exists())
542  info.dir().remove(info.fileName());
543 
544  std::string olderFile = appSett.getValue("Application.UserSettingsFile.<xmlattr>.xlink:href");
545 
546  appSett.setValue("Application.UserSettingsFile.<xmlattr>.xlink:href", fileName.toUtf8().data());
547 
548  if(removeOlder)
549  {
550  info.setFile(olderFile.c_str());
551  info.dir().remove(info.fileName());
552  }
553 
554  info.setFile(fileName);
555 
556  if(!info.exists())
557  {
558 #if BOOST_VERSION > 105600
559  boost::property_tree::xml_writer_settings<std::string> settings('\t', 1);
560 #else
561  boost::property_tree::xml_writer_settings<char> settings('\t', 1);
562 #endif
563  boost::property_tree::write_xml(fileName.toUtf8().data(), usrSett.getAllSettings(), std::locale(), settings);
564  }
565 
566  usrSett.load(fileName.toUtf8().data());
567 }
568 
569 //void te::qt::af::WriteDefaultProjectFile(const QString& fileName)
570 //{
571 // boost::property_tree::ptree p;
572 //
573 // std::string schema_location = te::core::FindInTerraLibPath("share/terralib/schemas/terralib/qt/af/project.xsd");
574 //
575 // //Header
576 // p.add("Project.<xmlattr>.xmlns:xsd", "http://www.w3.org/2001/XMLSchema-instance");
577 // p.add("Project.<xmlattr>.xmlns:te_map", "http://www.terralib.org/schemas/maptools");
578 // p.add("Project.<xmlattr>.xmlns:te_qt_af", "http://www.terralib.org/schemas/qt/af");
579 // p.add("Project.<xmlattr>.xmlns", "http://www.terralib.org/schemas/qt/af");
580 // p.add("Project.<xmlattr>.xsd:schemaLocation", "http://www.terralib.org/schemas/qt/af " + schema_location);
581 // p.add("Project.<xmlattr>.version", TERRALIB_VERSION_STRING);
582 //
583 // //Contents
584 // p.add("Project.Title", "Default project");
585 // p.add("Project.Author", "");
586 // p.add("Project.ComponentList", "");
587 // p.add("Project.te_map:LayerList", "");
588 //
589 // //Store file
590 //#if BOOST_VERSION > 105600
591 // boost::property_tree::xml_writer_settings<std::string> settings('\t', 1);
592 //#else
593 // boost::property_tree::xml_writer_settings<char> settings('\t', 1);
594 //#endif
595 // boost::property_tree::write_xml(fileName.toUtf8().data(), p, std::locale(), settings);
596 //}
597 
599 {
600  QString fileName = qApp->applicationDirPath() + "/../.generated";
601 
602  QFile f(fileName);
603  if (!f.open(QFile::ReadOnly | QFile::Text))
604  return "";
605 
606  QTextStream in(&f);
607  QString s = in.readAll();
608 
609  f.close();
610 
611  return s;
612 }
613 
614 void te::qt::af::GetDPIValuesFromSettings(int &dpiX, int &dpiY)
615 {
616  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
617 
618  QString widthMMStr = sett.value("display/screenWidthMM").toString();
619  QString heightMMStr = sett.value("display/screenHeightMM").toString();
620 
621  int widthMM = widthMMStr.toInt();
622  int heightMM = heightMMStr.toInt();
623 
624  QRect screenRect = QApplication::desktop()->screenGeometry();
625  int width = screenRect.width();
626  int height = screenRect.height();
627 
628  dpiX = (double)width/((double)widthMM/25.4);
629  dpiY = (double)height/((double)heightMM/25.4);
630 }
631 
632 bool te::qt::af::IsLowerVersion(const std::string& version1, const std::string& version2)
633 {
634  bool isLower = false;
635 
636  std::vector<std::string> vecVersion1;
637  std::vector<std::string> vecVersion2;
638 
639  te::common::Tokenize(version1, vecVersion1, ".");
640  te::common::Tokenize(version2, vecVersion2, ".");
641 
642  if (vecVersion1.size() < vecVersion2.size())
643  {
644  for (size_t i = vecVersion1.size(); i < vecVersion2.size(); ++i)
645  {
646  vecVersion1.push_back("0");
647  }
648  }
649  else if (vecVersion2.size() < vecVersion1.size())
650  {
651  for (size_t i = vecVersion2.size(); i < vecVersion1.size(); ++i)
652  {
653  vecVersion2.push_back("0");
654  }
655  }
656 
657  for (unsigned int i = 0; i < vecVersion1.size(); ++i)
658  {
659  int sub1 = atoi(vecVersion1[i].c_str());
660  int sub2 = atoi(vecVersion2[i].c_str());
661 
662  if (sub1 != sub2)
663  {
664  if (sub1 < sub2)
665  {
666  isLower = true;
667  }
668  break;
669  }
670  }
671 
672  return isLower;
673 }
674 
675 std::string GetUpperVersion(const std::vector<std::string>& versions)
676 {
677  if (versions.empty())
678  return "";
679 
680  std::string version = versions[0];
681  for (auto i : versions)
682  {
683  if (te::qt::af::IsLowerVersion(version, i))
684  version = i;
685  }
686 
687  return version;
688 }
689 
691 {
692  std::string userDir = appController->getUserDataDir().toUtf8().data();
693 
694  boost::filesystem::path folderP(userDir);
695  std::string folder = folderP.filename().string();
696 
697  std::vector<std::string> tokens;
698  te::common::Tokenize(folder, tokens, "-");
699 
700  std::string currentVersion = tokens[1];
701 
702  std::string organizationFolder = userDir + "/..";
703 
704  std::string appName = appController->getAppName().toUtf8().data();
705 
706  boost::filesystem::path p(organizationFolder);
707 
708  boost::filesystem::directory_iterator it(p), l;
709 
710  std::vector<std::string> appVersions;
711  for (boost::filesystem::directory_entry& entry : boost::make_iterator_range(it, l))
712  {
713  tokens.clear();
714 
715  std::string t = entry.path().filename().string();
716 
717  te::common::Tokenize(t, tokens, "-");
718 
719  if ((tokens[0] == appName) && (tokens[1] != currentVersion))
720  {
721  appVersions.push_back(tokens[1]);
722  }
723  }
724 
725  if (appVersions.empty())
726  return "";
727 
728  std::string upperVersion = GetUpperVersion(appVersions);
729 
730  std::string lastVersion = organizationFolder + "/" + appName + "-" + upperVersion;
731 
732  return lastVersion;
733 }
TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar *bar)
Removes a tool bar from the settings.
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
TEQTAFEXPORT std::vector< std::string > GetPluginsFiles()
TEQTAFEXPORT void AddActionToCustomToolbars(te::qt::af::ApplicationController *appController, QAction *act)
Check QSettings for existance of act and adds it if necessary.
An exception class for the TerraLib Application Framework.
TEQTAFEXPORT void SaveDataSourcesFile(te::qt::af::ApplicationController *appController)
Saves data sources file.
static void formatDataSourceInfos(const bool &encode)
Formats all data source informations registered in the te::da::DataSourceInfoManager object...
A singleton for managing application settings applied to a single user.
TEQTAFEXPORT void SetDateTime(const QString &dateTime)
The base API for TerraLib applications.
std::vector< PluginInfo > getBrokenPlugins() const
Return the list of plugins that could not be loaded.
TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved)
Unsaved star.
void setValue(const std::string &key, const std::string &value)
It stores the value according to the key.
TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString &dsType)
TEQTAFEXPORT void UpdateUserSettings()
Reads and return a te::qt::af::Project from the file.
TEQTAFEXPORT void SaveState(QMainWindow *mainWindow)
TEQTAFEXPORT void UpdateToolBarsInTheSettings(te::qt::af::ApplicationController *appController)
Update plugins file.
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
TEQTAFEXPORT void AddToolBarToSettings(QToolBar *bar)
Update settings with a new tool bar.
QToolBar * getToolBar(const QString &id) const
Return the toolbar identified by id or NULL if none is found.
std::string GetUpperVersion(const std::vector< std::string > &versions)
const QString & getAppName() const
Returns the application name.
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
Definition: StringUtils.h:221
static PluginManager & instance()
Access the singleton.
std::vector< PluginInfo > getUnloadedPlugins() const
Return the list of plugins that were not loaded.
TEQTAFEXPORT void UpdateUserSettingsFile(const QString &fileName, const bool &removeOlder=true)
Changes the user settings file location.
const QString & getAppPluginsPath() const
Returns the plugins file path of application.
static UserApplicationSettings & getInstance()
It returns a reference to the singleton instance.
TEQTAFEXPORT QString GetDefaultConfigFileOutputDir()
Returns the default path for output of configuration file.
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
TEQTAFEXPORT bool IsLowerVersion(const std::string &version1, const std::string &version2)
It compares two strings in the context of sistem version.
A singleton for managing application settings applied to the whole system (all users).
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
TEDATAACCESSEXPORT void Save(const std::string &fileName)
TEQTAFEXPORT void GetDPIValuesFromSettings(int &dpiX, int &dpiY)
Load setted dpi X and Y. If there is no configuration to load, it fills dpiX and dpiY with -1...
te::gm::Polygon * p
TEQTAFEXPORT void RestoreState(QMainWindow *mainWindow)
TEQTAFEXPORT QString GetGenerationDate()
Writes the configuration file. It updates the application settings.
TEQTAFEXPORT QString GetDateTime()
#define TERRALIB_APPLICATION_DATASOURCE_FILE_NAME
The default name for the application file containing the list of data sources.
void AddToolbarAndActions(QToolBar *bar, QSettings &sett)
TEQTAFEXPORT QString GetStyleSheetFromSettings()
Utility routines for the TerraLib Application Framework module.
QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: TableWidget.cpp:23
QAction * findAction(const QString &id) const
Returns the action identified by id or NULL if there&#39;s not an action identified by id...
void load(const std::string &fileName)
It tries to find a default config file based on system macros and default condigurations.
A class for xml serialization formatting strings.
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
TEQTAFEXPORT std::string GetLastFormerVersionPath(te::qt::af::ApplicationController *appController)
std::vector< QToolBar * > getToolBars() const
Return the list of registered toolbars.
const boost::property_tree::ptree & getAllSettings() const
It return a reading reference to the internal settings.
std::string getValue(const std::string &key)
It returns the value for a given key or empty.
TEQTAFEXPORT std::vector< std::string > GetPluginsNames(const std::vector< std::string > &plgFiles)
The base API for controllers of TerraLib applications.
std::vector< PluginInfo > getLoadedPlugins() const
Return the list of plugins that are loaded.
TEQTAFEXPORT std::vector< QToolBar * > ReadToolBarsFromSettings(te::qt::af::ApplicationController *appController, QWidget *barsParent=0)
Returns a vector of tool bars registered in the QSettings.
TEQTAFEXPORT QString GetLastDatasourceFromSettings()
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $
TEQTAFEXPORT std::vector< std::string > GetDefaultPluginsNames(te::qt::af::ApplicationController *appController)