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);
61 connect(
m_ui->m_symbolLibraryTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(
onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
67 m_ui->m_editSymbolPushButton->setVisible(
false);
81 dlg.setWindowTitle(title);
83 if(dlg.exec() == QDialog::Accepted)
91 Symbol* symbol = getSelectedSymbol();
96 return symbol->
clone();
101 Symbol* symbol = getSymbolFromItem(current);
106 m_preview->updatePreview(symbol);
111 Symbol* symbol = getSelectedSymbol();
125 QString path = QFileDialog::getOpenFileName(
this, tr(
"Select a TerraLib Symbol Library File"),
"",
"TerraLib Symbol Library Files (*.xml)");
136 QString message = tr(
"The selected symbol library could not be loaded.\n Details: )");
138 QMessageBox::critical(
this, tr(
"Error"), message);
144 QList<QTreeWidgetItem*> items = m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 0);
145 items.append(m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 1));
146 items.append(m_ui->m_symbolLibraryTreeWidget->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 2));
153 m_ui->m_symbolLibraryTreeWidget->clear();
156 std::pair<std::map<std::string, SymbolLibrary*>::const_iterator,
159 std::map<std::string, SymbolLibrary*>::const_iterator itLibrary;
160 for(itLibrary = iteratorsLibrary.first; itLibrary != iteratorsLibrary.second; ++itLibrary)
162 QString libraryName = QString::fromStdString(itLibrary->second->getName());
164 QTreeWidgetItem* libraryItem =
new QTreeWidgetItem(m_ui->m_symbolLibraryTreeWidget, LIBRARY);
165 libraryItem->setText(0, libraryName);
166 libraryItem->setData(0, Qt::UserRole, libraryName);
168 std::pair<std::map<std::string, Symbol*>::const_iterator,
169 std::map<std::string, Symbol*>::const_iterator> iteratorsSymbol = itLibrary->second->getIterator();
171 std::map<std::string, Symbol*>::const_iterator itSymbol;
173 for(itSymbol = iteratorsSymbol.first; itSymbol != iteratorsSymbol.second; ++itSymbol)
176 Symbol* symbol = itSymbol->second;
179 QTreeWidgetItem* symbolItem =
new QTreeWidgetItem(libraryItem, SYMBOL);
182 symbolItem->setToolTip(0, formatSymbolInfo(symbol->
getInfo()));
183 symbolItem->setData(0, Qt::UserRole, QVariant(QString(symbol->
getInfo().
m_id.c_str())));
190 m_ui->m_symbolLibraryTreeWidget->sortItems(0, Qt::AscendingOrder);
191 m_ui->m_symbolLibraryTreeWidget->resizeColumnToContents(0);
192 m_ui->m_symbolLibraryTreeWidget->expandAll();
197 for(
int i = 0; i < m_ui->m_symbolLibraryTreeWidget->topLevelItemCount(); ++i)
199 QTreeWidgetItem* library = m_ui->m_symbolLibraryTreeWidget->topLevelItem(i);
200 assert(library && library->type() == LIBRARY);
202 for(
int j = 0; j < library->childCount(); ++j)
204 QTreeWidgetItem* symbol = library->child(j);
205 assert(symbol && symbol->type() == SYMBOL);
206 bool hide = items.indexOf(symbol) == -1;
207 symbol->setHidden(hide);
215 QList<QTreeWidgetItem*> selected = m_ui->m_symbolLibraryTreeWidget->selectedItems();
220 return getSymbolFromItem(selected.at(0));
227 if(item->type() != SYMBOL)
231 QTreeWidgetItem* parent = item->parent();
234 QString name = parent->data(0, Qt::UserRole).toString();
235 assert(!name.isEmpty());
238 assert(symbolLibrary);
241 QString
id = item->data(0, Qt::UserRole).toString();
242 assert(!
id.isEmpty());
244 Symbol* symbol = symbolLibrary->findById(
id.toStdString());
252 QString information(
"<h3>Symbol Information</h3><ul>");
253 information +=
"<li><b>Name: </b>" + QString(info.
m_name.c_str()) +
"</li>";
254 information +=
"<li><b>Author: </b>" + QString(info.
m_author.c_str()) +
"</li>";
255 information +=
"<li><b>Tags: </b>" + QString(info.
m_tags.c_str()) +
"</li>";
256 information +=
"<li><b>Description: </b>" + QString(info.
m_description.c_str()) +
"</li>";
257 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. ...