27 #include "../../../common/Exception.h" 35 #include "ui_SymbolSelectorDialogForm.h" 39 #include <QFileDialog> 40 #include <QMessageBox> 47 m_ui(new
Ui::SymbolSelectorDialogForm)
51 m_ui->m_symbolLibraryTreeWidget->setIconSize(QSize(32, 32));
57 QGridLayout* previewLayout =
new QGridLayout(
m_ui->m_previewGroupBox);
67 m_ui->m_editSymbolPushButton->setVisible(
false);
79 dlg.setWindowTitle(title);
81 if(dlg.exec() == QDialog::Accepted)
94 return symbol->
clone();
102 if(symbol ==
nullptr)
112 if(symbol ==
nullptr)
124 QString path = QFileDialog::getOpenFileName(
this, tr(
"Select a TerraLib Symbol Library File"),
"",
"TerraLib Symbol Library Files (*.xml)");
135 QString message = tr(
"The selected symbol library could not be loaded.\n Details: )");
137 QMessageBox::critical(
this, tr(
"Error"), message);
143 QList<QTreeWidgetItem*> items =
m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 0);
144 items.append(
m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 1));
145 items.append(
m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 2));
152 m_ui->m_symbolLibraryTreeWidget->clear();
155 std::pair<std::map<std::string, SymbolLibrary*>::const_iterator,
158 std::map<std::string, SymbolLibrary*>::const_iterator itLibrary;
159 for(itLibrary = iteratorsLibrary.first; itLibrary != iteratorsLibrary.second; ++itLibrary)
161 QString libraryName = QString::fromUtf8(itLibrary->second->getName().c_str());
164 libraryItem->setText(0, libraryName);
165 libraryItem->setData(0, Qt::UserRole, libraryName);
167 std::pair<std::map<std::string, Symbol*>::const_iterator,
168 std::map<std::string, Symbol*>::const_iterator> iteratorsSymbol = itLibrary->second->getIterator();
170 std::map<std::string, Symbol*>::const_iterator itSymbol;
172 for(itSymbol = iteratorsSymbol.first; itSymbol != iteratorsSymbol.second; ++itSymbol)
175 Symbol* symbol = itSymbol->second;
182 symbolItem->setData(0, Qt::UserRole, QVariant(QString(symbol->
getInfo().
m_id.c_str())));
189 m_ui->m_symbolLibraryTreeWidget->sortItems(0, Qt::AscendingOrder);
190 m_ui->m_symbolLibraryTreeWidget->resizeColumnToContents(0);
191 m_ui->m_symbolLibraryTreeWidget->expandAll();
196 for(
int i = 0; i <
m_ui->m_symbolLibraryTreeWidget->topLevelItemCount(); ++i)
199 assert(library && library->type() ==
LIBRARY);
201 for(
int j = 0; j < library->childCount(); ++j)
204 assert(symbol && symbol->type() ==
SYMBOL);
205 bool hide = items.indexOf(symbol) == -1;
206 symbol->setHidden(hide);
214 QList<QTreeWidgetItem*> selected =
m_ui->m_symbolLibraryTreeWidget->selectedItems();
226 if(item->type() !=
SYMBOL)
233 QString name = parent->data(0, Qt::UserRole).toString();
234 assert(!name.isEmpty());
237 assert(symbolLibrary);
240 QString
id = item->data(0, Qt::UserRole).toString();
241 assert(!
id.isEmpty());
243 Symbol* symbol = symbolLibrary->findById(
id.toUtf8().data());
251 QString information(
"<h3>Symbol Information</h3><ul>");
252 information +=
"<li><b>Name: </b>" + QString(info.
m_name.c_str()) +
"</li>";
253 information +=
"<li><b>Author: </b>" + QString(info.
m_author.c_str()) +
"</li>";
254 information +=
"<li><b>Tags: </b>" + QString(info.
m_tags.c_str()) +
"</li>";
255 information +=
"<li><b>Description: </b>" + QString(info.
m_description.c_str()) +
"</li>";
256 information +=
"</ul>";
This class represents a symbol.
virtual const char * what() const
It outputs the exception message.
Static class used to generate preview of Symbology elements.
A dialog used to select a specific symbol.
The SymbolLibraryManager is a singleton that can be used to manage all loaded symbol libraries in Ter...
static SymbolLibraryManager & getInstance()
It returns a reference to the singleton instance.
This class represents a library of symbols.
A dialog used to configure informations about a symbol.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...