InternalSettingsDialog.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/InternalSettingsDialog.cpp
22 
23 \brief A Dialog to be used to inform about internal settings.
24 */
25 
26 #include "InternalSettingsDialog.h"
27 #include "ui_InternalSettingsDialogForm.h"
28 
29 // terralib includes
30 #include "../widgets/log/LogTextEdit.h"
31 #include "../../core/plugin/PluginManager.h"
32 #include "../../core/filesystem/FileSystem.h"
33 #include "../../common/PlatformUtils.h"
34 #include "../../common/TerraLib.h"
35 
36 // Qt includes
37 #include <QDesktopWidget>
38 
39 #if (QT_VERSION >= 0x050000)
40 #include <QStandardPaths>
41 #else
42 #include <QDesktopServices>
43 #endif
44 // Boost includes
45 #include <boost/filesystem.hpp>
46 
47 
49  : QDialog(parent, f),
50  m_ui(new Ui::InternalSettingsDialogForm)
51 {
52  //build form
53  m_ui->setupUi(this);
54 
55  //set path informations
56  setPaths();
57 
58  //set te modules information
59  setModules();
60 
61  //set te plugins information
62  setPlugins();
63 
64  //set system information
65  setSystemInfo();
66 
67  //set log reader
68  setLogReader();
69 
70  setWindowModality(Qt::NonModal);
71 
72  setAttribute(Qt::WA_DeleteOnClose);
73 }
74 
76 
78 {
79  m_ui->m_tabWidget->addTab(widget, tabName);
80 }
81 
83 {
84  //global
85  QString userDataDir;
86 
87 #if (QT_VERSION >= 0x050000)
88  userDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
89 #else
90  userDataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
91 #endif
92 
93  m_ui->m_userPathLineEdit->setText(userDataDir);
94 
95  m_ui->m_gdalDirLineEdit->setText(TERRALIB_GDAL_DATA);
96 
97  // terralib home
98  boost::filesystem::path curPath = te::core::FileSystem::currentPath();
99  m_ui->m_curPathLineEdit->setText(curPath.string().c_str());
100 
101  curPath /= "..";
102  m_ui->m_previousCurPathLineEdit->setText(curPath.string().c_str());
103 
104  std::string terraDir;
105  const char* teHomeEnv = getenv(TERRALIB_DIR_VAR_NAME);
106  if (teHomeEnv != nullptr)
107  terraDir = getenv(TERRALIB_DIR_VAR_NAME);
108  m_ui->m_terraLibHomeLineEdit->setText(terraDir.c_str());
109 
110  m_ui->m_installPrefixLineEdit->setText(TERRALIB_INSTALL_PREFIX_PATH);
111 
112  m_ui->m_codebasePathLineEdit->setText(TERRALIB_CODEBASE_PATH);
113 }
114 
116 {
117  m_ui->m_modulesListWidget->clear();
118 
119  std::size_t nModules = TerraLib::getInstance().getNumRegModules();
120 
121  for (std::size_t t = 0; t < nModules; ++t)
122  {
123  std::string name = TerraLib::getInstance().getModuleName(t);
124 
125  m_ui->m_modulesListWidget->addItem(name.c_str());
126  }
127 }
128 
130 {
131  m_ui->m_pluginsListWidget->clear();
132 
133  std::vector<std::string> plugins = te::core::PluginManager::instance().getPlugins();
134 
135  for (std::size_t t = 0; t < plugins.size(); ++t)
136  {
137  std::string name = plugins[t];
138 
139  m_ui->m_pluginsListWidget->addItem(name.c_str());
140  }
141 }
142 
144 {
145  m_ui->m_dpiXLineEdit->setText(QString::number(qApp->desktop()->logicalDpiX()));
146 
147  m_ui->m_dpiYLineEdit->setText(QString::number(qApp->desktop()->logicalDpiY()));
148 
149  m_ui->m_freePhysMemLineEdit->setText(QString("%L1").arg(te::common::GetFreePhysicalMemory()));
150 
151  m_ui->m_totalPhysMemLineEdit->setText(QString("%L1").arg(te::common::GetTotalPhysicalMemory()));
152 
153  m_ui->m_usedVirtualMemLineEdit->setText(QString("%L1").arg(te::common::GetUsedVirtualMemory()));
154 
155  m_ui->m_totalVirtualMemLineEdit->setText(QString("%L1").arg(te::common::GetTotalVirtualMemory()));
156 
157  m_ui->m_physProcNumberLineEdit->setText(QString::number(te::common::GetPhysProcNumber()));
158 }
159 
161 {
162 
163  m_ui->m_logNextPushButton->setIcon(QIcon::fromTheme("go-down"));
164  m_ui->m_logPreviousPushButton->setIcon(QIcon::fromTheme("go-up"));
165  m_ui->m_logClearPushButton->setIcon(QIcon::fromTheme("edit-clear"));
166 
167  connect(m_ui->m_logNextPushButton, SIGNAL(clicked(bool)), this,
168  SLOT(onFindNextClicked()));
169 
170  connect(m_ui->m_logPreviousPushButton, SIGNAL(clicked(bool)), this,
171  SLOT(onFindPreviousClicked()));
172 
173  connect(m_ui->m_logClearPushButton, SIGNAL(clicked(bool)),
174  m_ui->m_logTextEdit, SLOT(clear()));
175 
176  connect(m_ui->m_logFindLineEdit, SIGNAL(textChanged(const QString&)),
177  m_ui->m_logTextEdit, SLOT(findAll(const QString&)));
178 }
179 
181 {
182  m_ui->m_logTextEdit->find(m_ui->m_logFindLineEdit->text());
183 }
184 
185 
187 {
188  m_ui->m_logTextEdit->find(m_ui->m_logFindLineEdit->text(),
189  QTextDocument::FindBackward);
190 }
InternalSettingsDialog(QWidget *parent=0, Qt::WindowFlags f=0)
TECOMMONEXPORT unsigned long long int GetTotalVirtualMemory()
Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physic...
const std::string & getModuleName(std::size_t i) const
It return the i-th module name.
A Dialog to be used to inform about internal settings.
TECOMMONEXPORT unsigned int GetPhysProcNumber()
Returns the number of physical processors.
std::vector< std::string > getPlugins() const
Return the list of plugins managed by PluginManager.
static PluginManager & instance()
Access the singleton.
std::size_t getNumRegModules() const
It returns the number of registered modules.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
void addTab(QWidget *widget, QString tabName)
TECOMMONEXPORT unsigned long long int GetTotalPhysicalMemory()
Returns the amount of total physical memory (bytes).
Ui::InternalSettingsDialogForm * m_ui
static std::string currentPath()
Retrives the current working directory path in UTF-8.
Definition: FileSystem.cpp:50
TECOMMONEXPORT unsigned long long int GetFreePhysicalMemory()
Returns the amount of free physical memory (bytes).
TECOMMONEXPORT unsigned long long int GetUsedVirtualMemory()
Returns the amount of used virtual memory (bytes) for the current process (physical + swapped)...