All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Utils.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/Utils.cpp
22 
23  \brief Utility routines for the TerraLib Application Framework module.
24 */
25 
26 // TerraLib
27 #include "../../common/UserApplicationSettings.h"
28 #include "../../dataaccess/serialization/xml/Serializer.h"
29 #include "../../maptools/AbstractLayer.h"
30 #include "../../plugin/PluginManager.h"
31 #include "../../plugin/PluginInfo.h"
32 #include "../../serialization/maptools/Layer.h"
33 #include "../../xml/Reader.h"
34 #include "../../xml/ReaderFactory.h"
35 #include "../../xml/Writer.h"
36 #include "ApplicationController.h"
37 #include "ApplicationPlugins.h"
38 #include "Exception.h"
39 #include "Project.h"
40 #include "Utils.h"
41 
42 // STL
43 #include <cassert>
44 #include <fstream>
45 #include <memory>
46 
47 // Boost
48 #include <boost/filesystem.hpp>
49 #include <boost/format.hpp>
50 #include <boost/property_tree/ptree.hpp>
51 #include <boost/algorithm/string/replace.hpp>
52 
53 // Qt
54 #include <QtCore/QSettings>
55 #include <QtCore/QString>
56 #include <QtGui/QApplication>
57 #include <QtGui/QAction>
58 #include <QtGui/QMainWindow>
59 #include <QtGui/QMessageBox>
60 #include <QtGui/QToolBar>
61 
63 {
64  boost::filesystem::path furi(uri);
65 
66  if (!boost::filesystem::exists(furi) || !boost::filesystem::is_regular_file(furi))
67  throw Exception((boost::format(TR_QT_AF("Could not read project file: %1%.")) % uri).str());
68 
69  std::auto_ptr<te::xml::Reader> xmlReader(te::xml::ReaderFactory::make());
70 
71  xmlReader->read(uri);
72 
73  if(!xmlReader->next())
74  throw Exception((boost::format(TR_QT_AF("Could not read project information in the file: %1%.")) % uri).str());
75 
76  if(xmlReader->getNodeType() != te::xml::START_ELEMENT)
77  throw Exception((boost::format(TR_QT_AF("Error reading the document %1%, the start element wasn't found.")) % uri).str());
78 
79  if(xmlReader->getElementLocalName() != "Project")
80  throw Exception((boost::format(TR_QT_AF("The first tag in the document %1% is not 'Project'.")) % uri).str());
81 
82  Project* proj = ReadProject(*xmlReader);
83 
84  proj->setFileName(uri);
85 
86  return proj;
87 
88 }
89 
91 {
92  std::auto_ptr<Project> project(new Project);
93 
94  reader.next();
95  assert(reader.getNodeType() == te::xml::START_ELEMENT);
96  assert(reader.getElementLocalName() == "Title");
97 
98  reader.next();
99  assert(reader.getNodeType() == te::xml::VALUE);
100  project->setTitle(reader.getElementValue());
101  reader.next(); // End element
102 
103  reader.next();
104  assert(reader.getNodeType() == te::xml::START_ELEMENT);
105  assert(reader.getElementLocalName() == "Author");
106 
107  reader.next();
108 
109  if(reader.getNodeType() == te::xml::VALUE)
110  {
111  project->setAuthor(reader.getElementValue());
112  reader.next(); // End element
113  }
114 
115  reader.next();
116  assert(reader.getNodeType() == te::xml::START_ELEMENT);
117  assert(reader.getElementLocalName() == "ComponentList");
118  reader.next(); // End element
119  reader.next(); // next after </ComponentList>
120 
121  assert(reader.getNodeType() == te::xml::START_ELEMENT);
122  assert(reader.getElementLocalName() == "LayerList");
123 
124  reader.next();
125 
127 
128  // Read the layers
129  std::vector<std::string> invalidLayers;
130 
131  while((reader.getNodeType() != te::xml::END_ELEMENT) &&
132  (reader.getElementLocalName() != "LayerList"))
133  {
134  te::map::AbstractLayerPtr layer(lserial.read(reader));
135 
136  assert(layer.get());
137 
138  if(layer->isValid())
139  project->add(layer);
140  else
141  invalidLayers.push_back(layer->getTitle());
142  }
143 
144  assert(reader.getNodeType() == te::xml::END_ELEMENT);
145  assert(reader.getElementLocalName() == "LayerList");
146 
147  reader.next();
148  assert((reader.getNodeType() == te::xml::END_ELEMENT) || (reader.getNodeType() == te::xml::END_DOCUMENT));
149  assert(reader.getElementLocalName() == "Project");
150 
151  project->setProjectAsChanged(false);
152 
153  if(!invalidLayers.empty())
154  {
155  QString message(QObject::tr("The following layers are invalid and will not be added to TerraView"));
156 
157  message += "<ul>";
158  for(std::size_t i = 0; i <invalidLayers.size(); ++i)
159  {
160  message += "<li>";
161  message += invalidLayers[i].c_str();
162  message += "</li>";
163  }
164  message += "</ul>";
165 
166  QMessageBox::information(te::qt::af::ApplicationController::getInstance().getMainWindow(), te::qt::af::ApplicationController::getInstance().getAppTitle(), message);
167  }
168 
169  return project.release();
170 }
171 
172 void te::qt::af::Save(const te::qt::af::Project& project, const std::string& uri)
173 {
174  std::ofstream fout(uri.c_str(), std::ios_base::trunc);
175 
176  te::xml::Writer w(fout);
177 
178  Save(project, w);
179 
180  fout.close();
181 }
182 
184 {
185  const char* te_env = getenv("TERRALIB_DIR");
186 
187  if(te_env == 0)
188  throw Exception(TR_QT_AF("Environment variable \"TERRALIB_DIR\" not found.\nTry to set it before run the application."));
189 
190  std::string schema_loc(te_env);
191  schema_loc += "/schemas/terralib";
192 
193  writer.writeStartDocument("UTF-8", "no");
194 
195  writer.writeStartElement("Project");
196 
197  boost::replace_all(schema_loc, " ", "%20");
198 
199  schema_loc = "file:///" + schema_loc;
200 
201  writer.writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema-instance");
202  writer.writeAttribute("xmlns:te_da", "http://www.terralib.org/schemas/dataaccess");
203  writer.writeAttribute("xmlns:te_map", "http://www.terralib.org/schemas/maptools");
204  writer.writeAttribute("xmlns:te_qt_af", "http://www.terralib.org/schemas/common/af");
205 
206  writer.writeAttribute("xmlns:se", "http://www.opengis.net/se");
207  writer.writeAttribute("xmlns:ogc", "http://www.opengis.net/ogc");
208  writer.writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
209 
210  writer.writeAttribute("xmlns", "http://www.terralib.org/schemas/qt/af");
211  writer.writeAttribute("xsd:schemaLocation", "http://www.terralib.org/schemas/qt/af " + schema_loc + "/qt/af/project.xsd");
212  writer.writeAttribute("version", TERRALIB_STRING_VERSION);
213 
214  writer.writeElement("Title", project.getTitle());
215  writer.writeElement("Author", project.getAuthor());
216 
217  writer.writeStartElement("ComponentList");
218  writer.writeEndElement("ComponentList");
219 
220  writer.writeStartElement("te_map:LayerList");
221 
223 
224  for(std::list<te::map::AbstractLayerPtr>::const_iterator it = project.getTopLayers().begin();
225  it != project.getTopLayers().end();
226  ++it)
227  lserial.write(it->get(), writer);
228 
229  writer.writeEndElement("te_map:LayerList");
230 
231  writer.writeEndElement("Project");
232 }
233 
234 void te::qt::af::UpdateUserSettings(const QStringList& prjFiles, const QStringList& prjTitles, const std::string& userConfigFile)
235 {
236  // Recent projects
237  //----------------
238  if(prjFiles.empty())
239  return;
240 
241  boost::property_tree::ptree& p = te::common::UserApplicationSettings::getInstance().getAllSettings();
242 
243  p.get_child("UserSettings.MostRecentProject.<xmlattr>.xlink:href").put_value(prjFiles.at(0).toStdString());
244  p.get_child("UserSettings.MostRecentProject.<xmlattr>.title").put_value(prjTitles.at(0).toStdString());
245 
246  if(prjFiles.size() > 1)
247  {
248  boost::property_tree::ptree recPrjs;
249 
250  for(int i=1; i<prjFiles.size(); i++)
251  {
252  boost::property_tree::ptree prj;
253 
254  prj.add("<xmlattr>.xlink:href", prjFiles.at(i).toStdString());
255  prj.add("<xmlattr>.title", prjTitles.at(i).toStdString());
256 
257  recPrjs.add_child("Project", prj);
258  }
259 
260  p.put_child("UserSettings.RecentProjects", recPrjs);
261  }
262 
263  //Enabled plugins
264  //----------------
265  boost::property_tree::ptree plgs;
266  std::vector<std::string> plugins;
267  std::vector<std::string>::iterator it;
268  te::plugin::PluginManager::getInstance().getPlugins(plugins);
269 
270  for(it=plugins.begin(); it!=plugins.end(); ++it)
271  if(te::plugin::PluginManager::getInstance().isLoaded(*it))
272  {
273  boost::property_tree::ptree plg;
274  plg.put_value(*it);
275  plgs.add_child("Plugin", plg);
276  }
277 
278  p.put_child("UserSettings.EnabledPlugins", plgs);
279 
281 }
282 
284 {
285  std::string fileName = te::common::UserApplicationSettings::getInstance().getValue("UserSettings.DataSourcesFile");
286 
287  if(fileName.empty())
288  return;
289 
290  te::serialize::xml::Save(fileName);
291 }
292 
294 {
295  ApplicationPlugins::getInstance().getAllSettings().get_child("Plugins").erase("Plugin");
296  boost::property_tree::ptree& p = ApplicationPlugins::getInstance().getAllSettings();
297 
298  std::vector<std::string> plugins;
299  std::vector<std::string>::iterator it;
300  te::plugin::PluginManager::getInstance().getPlugins(plugins);
301 
302  for(it=plugins.begin(); it!=plugins.end(); ++it)
303  {
304  const te::plugin::PluginInfo& info = te::plugin::PluginManager::getInstance().getPlugin(*it);
305  boost::property_tree::ptree plg;
306 
307  std::string plgFileName = info.m_folder + "/" + info.m_name + ".teplg";
308 
309  plg.add("Name", info.m_name);
310  plg.add("Path.<xmlattr>.xlink:href", plgFileName);
311 
312  p.add_child("Plugins.Plugin", plg);
313  }
314 
315  // Store the file.
316  boost::property_tree::xml_writer_settings<char> settings('\t', 1);
317  boost::property_tree::write_xml(ApplicationPlugins::getInstance().getFileName(), p, std::locale(), settings);
318 }
319 
320 void AddToolbarAndActions(QToolBar* bar, QSettings& sett)
321 {
322  sett.beginGroup(bar->objectName());
323 
324  sett.setValue("name", bar->objectName());
325 
326  sett.beginWriteArray("Actions");
327 
328  QList<QAction*> acts = bar->actions();
329 
330  for(int i=0; i<acts.size(); i++)
331  {
332  sett.setArrayIndex(i);
333  sett.setValue("action", acts.at(i)->objectName());
334  }
335 
336  sett.endArray();
337 
338  sett.endGroup();
339 }
340 
342 {
343  std::vector<QToolBar*> bars = te::qt::af::ApplicationController::getInstance().getToolBars();
344  std::vector<QToolBar*>::const_iterator it;
345  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
346 
347  sett.beginGroup("toolbars");
348 
349  for (it = bars.begin(); it != bars.end(); ++it)
350  {
351  QToolBar* bar = *it;
352 
353  sett.remove(bar->objectName());
354 
355  AddToolbarAndActions(bar, sett);
356  }
357 
358  sett.endGroup();
359 }
360 
362 {
363  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
364 
365  sett.beginGroup("toolbars");
366 
367  AddToolbarAndActions(bar, sett);
368 
369  sett.endGroup();
370 }
371 
373 {
374  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
375 
376  sett.beginGroup("toolbars");
377  sett.remove(bar->objectName());
378  sett.endGroup();
379 }
380 
381 std::vector<QToolBar*> te::qt::af::ReadToolBarsFromSettings(QWidget* barsParent)
382 {
383  std::vector<QToolBar*> bars;
384 
385  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
386 
387  sett.beginGroup("toolbars");
388  QStringList lst = sett.childGroups();
389 
390  QStringList::iterator it;
391 
392  for(it=lst.begin(); it != lst.end(); ++it)
393  {
394  QString gr = *it;
395 
396  sett.beginGroup(gr);
397 
398  QString grName = sett.value("name").toString();
399 
400  int size = sett.beginReadArray("Actions");
401 
402  QToolBar* toolbar = new QToolBar(barsParent);
403  toolbar->setObjectName(grName);
404  toolbar->setWindowTitle(grName);
405 
406  for(int i=0; i<size; i++)
407  {
408  sett.setArrayIndex(i);
409  QString act = sett.value("action").toString();
410 
411  if(act == "")
412  {
413  toolbar->addSeparator();
414  }
415  else
416  {
417  QAction* a = ApplicationController::getInstance().findAction(act);
418 
419  if(a != 0)
420  toolbar->addAction(a);
421  }
422  }
423 
424  sett.endArray();
425  sett.endGroup();
426 
427  bars.push_back(toolbar);
428  }
429 
430  sett.endGroup();
431 
432  return bars;
433 }
434 
435 void te::qt::af::SaveState(QMainWindow* mainWindow)
436 {
437  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
438 
439  sett.beginGroup("mainWindow");
440  sett.setValue("geometry", mainWindow->saveGeometry());
441  sett.setValue("windowState", mainWindow->saveState());
442  sett.endGroup();
443 }
444 
445 void te::qt::af::RestoreState(QMainWindow* mainWindow)
446 {
447  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
448 
449  sett.beginGroup("mainWindow");
450  mainWindow->restoreGeometry(sett.value("geometry").toByteArray());
451  mainWindow->restoreState(sett.value("windowState").toByteArray());
452  sett.endGroup();
453 }
454 
455 void te::qt::af::GetProjectInformationsFromSettings(QString& defaultAuthor, int& maxSaved)
456 {
457  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
458 
459  sett.beginGroup("projects");
460  defaultAuthor = sett.value("default author").toString();
461  maxSaved = sett.value("maximum saved").toInt();
462  sett.endGroup();
463 }
464 
465 void te::qt::af::SaveProjectInformationsOnSettings(const QString& defaultAuthor, const int& maxSaved)
466 {
467  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
468 
469  sett.beginGroup("projects");
470  sett.setValue("default author", defaultAuthor);
471  sett.setValue("maximum saved", maxSaved);
472  sett.endGroup();
473 }
474 
475 void te::qt::af::SaveLastDatasourceOnSettings(const QString& dsType)
476 {
477  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
478 
479  sett.setValue("projects/last datasource used", dsType);
480 }
481 
483 {
484  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
485 
486  sett.setValue("projects/openLastDataSource", openLast);
487 }
488 
490 {
491  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
492 
493  return sett.value("projects/last datasource used").toString();
494 }
495 
497 {
498  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
499 
500  QVariant variant = sett.value("projects/openLastDataSource");
501 
502  // If the option was never edited
503  if(variant.isNull() || !variant.isValid())
504  return true;
505 
506  return variant.toBool();
507 }
508 
510 {
511  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
512 
513  sett.beginGroup("toolbars");
514 
515  sett.beginGroup("File Tool Bar");
516  sett.setValue("name", "File Tool Bar");
517  sett.beginWriteArray("Actions");
518  sett.setArrayIndex(0);
519  sett.setValue("action", "File.New Project");
520  sett.setArrayIndex(1);
521  sett.setValue("action", "File.Open Project");
522  sett.setArrayIndex(2);
523  sett.setValue("action", "File.Save Project");
524  sett.setArrayIndex(3);
525  sett.setValue("action", "");
526  sett.setArrayIndex(4);
527  sett.setValue("action", "Project.New Folder");
528  sett.setArrayIndex(5);
529  sett.setValue("action", "Project.Add Layer.All Sources");
530  sett.endArray();
531  sett.endGroup();
532 
533  sett.beginGroup("View Tool Bar");
534  sett.setValue("name", "View Tool Bar");
535  sett.beginWriteArray("Actions");
536  sett.setArrayIndex(0);
537  sett.setValue("action", "View.Layer Explorer");
538  sett.setArrayIndex(1);
539  sett.setValue("action", "View.Map Display");
540  sett.setArrayIndex(2);
541  sett.setValue("action", "View.Data Table");
542  sett.setArrayIndex(3);
543  sett.setValue("action", "View.Style Explorer");
544  sett.endArray();
545  sett.endGroup();
546 
547  sett.beginGroup("Map Tool Bar");
548  sett.setValue("name", "Map Tool Bar");
549  sett.beginWriteArray("Actions");
550  sett.setArrayIndex(0);
551  sett.setValue("action", "Map.Draw");
552  sett.setArrayIndex(1);
553  sett.setValue("action", "Map.Previous Extent");
554  sett.setArrayIndex(2);
555  sett.setValue("action", "Map.Next Extent");
556  sett.setArrayIndex(3);
557  sett.setValue("action", "Map.Zoom Extent");
558  sett.setArrayIndex(4);
559  sett.setValue("action", "");
560  sett.setArrayIndex(5);
561  sett.setValue("action", "Map.Zoom In");
562  sett.setArrayIndex(6);
563  sett.setValue("action", "Map.Zoom Out");
564  sett.setArrayIndex(7);
565  sett.setValue("action", "Map.Pan");
566  sett.setArrayIndex(8);
567  sett.setValue("action", "");
568  sett.setArrayIndex(9);
569  sett.setValue("action", "Map.Info");
570  sett.setArrayIndex(10);
571  sett.setValue("action", "Map.Selection");
572  sett.endArray();
573  sett.endGroup();
574 
575  sett.endGroup();
576 
577  sett.beginGroup("projects");
578 
579  sett.setValue("default author", "");
580  sett.setValue("maximum saved", "8");
581 
582  sett.endGroup();
583 }
584 
585 QString te::qt::af::UnsavedStar(const QString windowTitle, bool isUnsaved)
586 {
587  QString result(windowTitle);
588 
589  if(isUnsaved)
590  {
591  if(result.at(result.count()-1) != '*')
592  result += "*";
593  }
594  else
595  {
596  if(result.at(result.count()-1) == '*')
597  result.remove((result.count()-1), 1);
598  }
599 
600  return result;
601 }
602 
604 {
605  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
606  QString hexColor = sett.value("display/defaultDisplayColor").toString();
607  QColor defaultColor;
608  defaultColor.setNamedColor(hexColor);
609  if(!defaultColor.isValid())
610  return Qt::white;
611 
612  return defaultColor;
613 }
614 
615 QString te::qt::af::GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
616 {
617  QString sty("alternate-background-color: ");
618  sty += "rgb(" + QString::number(secondaryColor.red()) + ", " + QString::number(secondaryColor.green());
619  sty += ", " + QString::number(secondaryColor.blue()) + ")";
620  sty += ";background-color: rgb(" + QString::number(primaryColor.red()) + ", " + QString::number(primaryColor.green());
621  sty += ", " + QString::number(primaryColor.blue()) + ");";
622 
623  return sty;
624 }
625 
627 {
628  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
629  //bool isChecked = sett.value("table/tableAlternateColors").toBool();
630  QColor pColor;
631  pColor.setNamedColor(sett.value("table/primaryColor").toString());
632  QColor sColor;
633  sColor.setNamedColor(sett.value("table/secondaryColor").toString());
634 
635  if(!pColor.isValid())
636  pColor = Qt::white;
637  if(!sColor.isValid())
638  sColor = Qt::white;
639 
640  return GetStyleSheetFromColors(pColor, sColor);
641 }
642 
644 {
645  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
646  bool isChecked = sett.value("table/tableAlternateColors").toBool();
647 
648  return isChecked;
649 }
650 
652 {
653  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
654 
655  sett.beginGroup("toolbars");
656  QStringList lst = sett.childGroups();
657  QStringList::iterator it;
658 
659  for(it=lst.begin(); it!=lst.end(); ++it)
660  {
661  int size = sett.beginReadArray(*it+"/Actions");
662 
663  for(int i=0; i<size; i++)
664  {
665  sett.setArrayIndex(i);
666 
667  QString v = sett.value("action").toString();
668 
669  if (v == act->objectName())
670  {
671  ApplicationController::getInstance().getToolBar(*it)->addAction(act);
672  break;
673  }
674  }
675 
676  sett.endArray();
677  }
678 
679  sett.endGroup();
680 }
681 
virtual void writeStartDocument(const std::string &encoding, const std::string &standalone)
Definition: Writer.cpp:39
The basic information about a plugin.
Definition: PluginInfo.h:61
TEQTAFEXPORT void AddToolBarToSettings(QToolBar *bar)
Update settings with a new tool bar.
Definition: Utils.cpp:361
An exception class for the TerraLib Application Framework.
const std::string & getAuthor() const
It gets the author of the project.
Definition: Project.cpp:62
TEDATAACCESSEXPORT void Save(const std::string &fileName)
Definition: Serializer.cpp:191
TEQTAFEXPORT bool GetAlternateRowColorsFromSettings()
Definition: Utils.cpp:643
te::map::AbstractLayer * read(te::xml::Reader &reader) const
Definition: Layer.cpp:681
This class models a XML reader object.
Definition: Reader.h:55
TEQTAFEXPORT void RemoveToolBarFromSettings(QToolBar *bar)
Removes a tool bar from the settings.
Definition: Utils.cpp:372
Utility routines for the TerraLib Application Framework module.
TEQTAFEXPORT void UpdateToolBarsInTheSettings()
Update the existing tool bars.
Definition: Utils.cpp:341
The base API for controllers of TerraLib applications.
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
const boost::property_tree::ptree & getAllSettings() const
It return a reading reference to the internal settings.
virtual bool next()=0
It gets the next event to be read.
TEQTAFEXPORT QString UnsavedStar(const QString windowTitle, bool isUnsaved)
Unsaved star.
Definition: Utils.cpp:585
std::string getValue(const std::string &key)
It returns the value for a given key or empty.
static ApplicationController & getInstance()
It gives access to the controller singleton.
TEQTAFEXPORT void SaveProjectInformationsOnSettings(const QString &defaultAuthor, const int &maxSaved)
Definition: Utils.cpp:465
TEQTAFEXPORT Project * ReadProject(const std::string &uri)
Reads and return a te::qt::af::Project from the file.
Definition: Utils.cpp:62
QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: TableWidget.cpp:23
TEQTAFEXPORT void SaveDataSourcesFile()
Saves data sources file.
Definition: Utils.cpp:283
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
Definition: Utils.cpp:603
virtual void writeStartElement(const std::string &qName)
Definition: Writer.cpp:44
virtual void writeAttribute(const std::string &attName, const std::string &value)
Definition: Writer.cpp:90
This class models the concept of a project for the TerraLib Application Framework.
Definition: Project.h:50
void setFileName(const std::string &fName)
It sets the filename where the project will be saved.
Definition: Project.cpp:183
virtual std::string getElementValue() const =0
It returns the element data value in the case of VALUE node.
virtual void writeEndElement(const std::string &qName)
Definition: Writer.cpp:156
TEQTAFEXPORT void SaveState(QMainWindow *mainWindow)
Definition: Utils.cpp:435
void AddToolbarAndActions(QToolBar *bar, QSettings &sett)
Definition: Utils.cpp:320
TEQTAFEXPORT void RestoreState(QMainWindow *mainWindow)
Definition: Utils.cpp:445
const std::string & getTitle() const
It gets the title of the project.
Definition: Project.cpp:51
TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString &dsType)
Definition: Utils.cpp:475
A singleton for managing the application plugins.
TEQTAFEXPORT QString GetStyleSheetFromColors(QColor primaryColor, QColor secondaryColor)
Definition: Utils.cpp:615
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:234
std::vector< QToolBar * > getToolBars() const
Return the list of registered toolbars.
virtual void writeElement(const std::string &qName, const std::string &value)
Definition: Writer.cpp:54
const std::list< te::map::AbstractLayerPtr > & getTopLayers() const
It gets all the top layers of the project (folder and single layers).
Definition: Project.cpp:67
void changed()
This method can be used by clients to inform manually that the internal state has changed...
TEQTAFEXPORT void CreateDefaultSettings()
Creates a default QSettings.
Definition: Utils.cpp:509
TEQTAFEXPORT bool GetOpenLastProjectFromSettings()
Definition: Utils.cpp:496
TEQTAFEXPORT void Save(const Project &project, const std::string &uri)
Saves the informations of the project in the uri file.
Definition: Utils.cpp:172
void write(const te::map::AbstractLayer *alayer, te::xml::Writer &writer) const
Definition: Layer.cpp:695
TEQTAFEXPORT QString GetStyleSheetFromSettings()
Definition: Utils.cpp:626
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
#define TR_QT_AF(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
Definition: Config.h:77
static Layer & getInstance()
It returns a reference to the singleton instance.
virtual NodeType getNodeType() const =0
It return the type of node read.
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
This class models the concept of a project for the TerraLib Application Framework.
TEQTAFEXPORT QString GetLastDatasourceFromSettings()
Definition: Utils.cpp:489
std::string m_folder
The plugin folder (where the plugin is installed).
Definition: PluginInfo.h:78
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
TEQTAFEXPORT void UpdateApplicationPlugins()
Update plugins file.
Definition: Utils.cpp:293
TEQTAFEXPORT void SaveOpenLastProjectOnSettings(bool openLast)
Definition: Utils.cpp:482
TEQTAFEXPORT std::vector< QToolBar * > ReadToolBarsFromSettings(QWidget *barsParent=0)
Returns a vector of tool bars registered in the QSettings.
Definition: Utils.cpp:381
TEQTAFEXPORT void GetProjectInformationsFromSettings(QString &defaultAuthor, int &maxSaved)
Definition: Utils.cpp:455
TEQTAFEXPORT void AddActionToCustomToolbars(QAction *act)
Check QSettings for existance of act and adds it if necessary.
Definition: Utils.cpp:651
This class models a XML writer object.
Definition: Writer.h:52