SymbolSelectorDialog.h
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/widgets/se/SymbolSelectorDialog.h
22 
23  \brief A dialog used to select a specific symbol.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SE_INTERNAL_SYMBOLSELECTORDIALOG_H
27 #define __TERRALIB_QT_WIDGETS_SE_INTERNAL_SYMBOLSELECTORDIALOG_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // Qt
33 #include <QDialog>
34 #include <QStringListIterator>
35 
36 // STL
37 #include <memory>
38 #include <string>
39 #include <vector>
40 
41 // Forward declaraion
42 class QTreeWidgetItem;
43 class QTreeWidget;
44 class QString;
45 
46 namespace Ui
47 {
48  class SymbolSelectorDialogForm;
49 }
50 
51 namespace te
52 {
53  // Forward declarations
54  namespace se
55  {
56  class Rule;
57  }
58  namespace qt
59  {
60  namespace widgets
61  {
62  // Forward declarations
63  class Symbol;
64  struct SymbolInfo;
65  class SymbolPreviewWidget;
66  class SymbolNode;
67 
68  /*!
69  \class SymbolSelectorDialog
70 
71  \brief A dialog used to select a specific symbol.
72  */
73  class TEQTWIDGETSEXPORT SymbolSelectorDialog : public QDialog
74  {
75  Q_OBJECT
76 
77  private:
78 
79  /*!
80  \enum NodeType
81 
82  \brief Auxiliary internal enumeration to control the tree nodes.
83  */
84  enum NodeType
85  {
86  GROUP = 0, /*!< Library root node. */
87  SYMBOL = 1, /*!< Symbol node. */
88  };
89 
90  public:
91 
92  /** @name Initializer Methods
93  * Methods related to instantiation and destruction.
94  */
95  //@{
96 
97  /*!
98  \brief Constructs a symbol selector dialog which is a child of parent, with widget flags set to f.
99 
100  \note field names from dataset for text symbolizer (no geometry)
101 
102  */
103  SymbolSelectorDialog(const std::vector<std::string>& fieldsNames, QWidget* parent = 0, Qt::WindowFlags f = 0);
104 
105  /*! \brief Destructor. */
107 
108  /*! \brief Auxiliary internal method that returns the selected symbol.
109  */
111 
112  /*!
113  \brief Gets the selected symbol.
114 
115  \return The selected fill element.
116 
117  \note The caller will take the ownership of the returned symbol.
118  \note It return a NULL pointer if there is not a selected symbol.
119  */
120  Symbol* getSymbol() const;
121 
122  private slots:
123 
124  void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
125 
127 
129 
131 
132  void onSearchLineEditTextChanged(const QString& text);
133 
135 
137 
139 
141 
143 
145 
147 
149 
151 
152  void onDropEvent();
153 
155 
156  private:
157 
158  /*! \brief Initialize the dialog. */
159  void initialize();
160 
161  /*! \brief Auxiliary internal method to filter the symbols. */
162  void filter(const QList<QTreeWidgetItem*>& items);
163 
164  /*! \brief Auxiliary internal method that returns the symbol given a list widget item. */
165  Symbol* getSymbolFromItem(QTreeWidgetItem* item) const;
166 
167  /*! \brief Auxiliary internal method to format a symbol info to be used on tool tips. */
168  QString formatSymbolInfo(const SymbolInfo& info) const;
169 
170  /*! \brief Add new symbol to a symbol library. */
171  bool addSymbol(Symbol* symbol, const QString& groupParentId);
172 
173  /*!
174  \brief Update the current selected symbol.
175 
176  \note The symbol with the old state will be removed, and a new one with the same id and name will be added to the library.
177  */
179 
180  /*!
181  \brief Remove a symbol from a symbol library .
182 
183  \note The symbol is removed, but the pointer is not deleted.
184  */
185  bool removeSymbol(Symbol* symbol);
186 
187  /*!
188  \brief Remove a symbol from a symbol library .
189 
190  \note The symbol is removed, but the pointer is not deleted.
191  */
192  bool eraseSymbol(Symbol* symbol);
193 
194  /*!
195  \brief Remove the current selected symbol from a symbol library.
196 
197  \note The symbol is removed, but the pointer is not deleted.
198  */
200 
201  /*! \brief Add new symbol to a symbol library. */
202  bool addGroup(const QString& groupName, const QString& groupParentId);
203 
204  /*!
205  \brief Update the current selected symbol.
206 
207  \note The symbol with the old state will be removed, and a new one with the same id and name will be added to the library.
208  */
209  bool updateCurrentGroup(const QString& newGroupName, const QString& groupId);
210 
211  /*!
212  \brief Remove a symbol from a symbol library .
213 
214  \note The symbol is removed, but the pointer is not deleted.
215  */
216  bool eraseGroup(const QString& groupId);
217 
218  /*!
219  \brief Remove the current selected symbol from a symbol library.
220 
221  \note The symbol is removed, but the pointer is not deleted.
222  */
224 
225  /*!
226  \brief Get the current selected symbol.
227  */
228  QTreeWidgetItem* getSelectedItem() const;
229 
230  void buildTree(SymbolNode* node, QTreeWidgetItem* parent);
231 
232  QTreeWidgetItem* createItemFromGroup(SymbolNode* node, QTreeWidgetItem* parent = nullptr);
233 
234  QTreeWidgetItem* createItemFromGroup(SymbolNode* node, QTreeWidget* parent);
235 
236  QTreeWidgetItem* createItemFromSymbol(Symbol* symbol, QTreeWidgetItem* parent = nullptr);
237 
238  QTreeWidgetItem* createItemFromSymbol(Symbol* symbol, QTreeWidget* parent);
239 
240  void configItemFromSymbol(Symbol* symbol, QTreeWidgetItem* item);
241 
242  void enableSymbolItem(bool enable);
243 
244  void enableGroupItem(bool enable);
245 
246  QTreeWidgetItem* getCurrentGroupItem();
247 
249 
250  QTreeWidgetItem* searchParentGroup(QTreeWidgetItem* item);
251 
252  QString getSelectedItemID();
253 
254  bool isRootItem(QTreeWidgetItem* item);
255 
256  private:
257 
258  std::unique_ptr<Ui::SymbolSelectorDialogForm> m_ui; //!< Dialog form.
259  SymbolPreviewWidget* m_preview; //!< Preview Widget used to visualize the symbol.
260  std::vector<std::string> m_fieldsNames; //!< Dataset fields names for text symbolizer (no geometry)
261  QTreeWidgetItem* m_currentDragDropItem;
262  };
263 
264  } // end namespace widgets
265  } // end namespace qt
266 } // end namespace te
267 
268 #endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_SYMBOLSELECTORDIALOG_H
te::qt::widgets::SymbolInfo
Information about a given Symbol.
Definition: SymbolInfo.h:61
te::qt::widgets::SymbolSelectorDialog::getSymbolFromItem
Symbol * getSymbolFromItem(QTreeWidgetItem *item) const
Auxiliary internal method that returns the symbol given a list widget item.
te::qt::widgets::SymbolSelectorDialog::eraseCurrentSymbol
bool eraseCurrentSymbol()
Remove the current selected symbol from a symbol library.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::qt::widgets::SymbolSelectorDialog::onCurrentItemChanged
void onCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
te::qt::widgets::SymbolSelectorDialog::onSearchLineEditTextChanged
void onSearchLineEditTextChanged(const QString &text)
te::qt::widgets::SymbolSelectorDialog::onExportButtonPressed
void onExportButtonPressed()
te::qt::widgets::SymbolSelectorDialog::onCreateGroupPushButtonClicked
void onCreateGroupPushButtonClicked()
te::qt::widgets::SymbolSelectorDialog::getCurrentGroupItemID
QString getCurrentGroupItemID()
te::qt::widgets::SymbolSelectorDialog::searchParentGroup
QTreeWidgetItem * searchParentGroup(QTreeWidgetItem *item)
te::qt::widgets::SymbolSelectorDialog::createItemFromSymbol
QTreeWidgetItem * createItemFromSymbol(Symbol *symbol, QTreeWidget *parent)
te::qt::widgets::SymbolSelectorDialog::configItemFromSymbol
void configItemFromSymbol(Symbol *symbol, QTreeWidgetItem *item)
te::qt::widgets::SymbolSelectorDialog::SymbolSelectorDialog
SymbolSelectorDialog(const std::vector< std::string > &fieldsNames, QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a symbol selector dialog which is a child of parent, with widget flags set to f.
te::qt::widgets::SymbolSelectorDialog::m_fieldsNames
std::vector< std::string > m_fieldsNames
Dataset fields names for text symbolizer (no geometry)
Definition: SymbolSelectorDialog.h:260
te::qt::widgets::SymbolSelectorDialog::getSelectedSymbol
Symbol * getSelectedSymbol() const
Auxiliary internal method that returns the selected symbol.
te::qt::widgets::SymbolSelectorDialog::addSymbol
bool addSymbol(Symbol *symbol, const QString &groupParentId)
Add new symbol to a symbol library.
te::qt::widgets::SymbolSelectorDialog::filter
void filter(const QList< QTreeWidgetItem * > &items)
Auxiliary internal method to filter the symbols.
te::qt::widgets::SymbolSelectorDialog::createItemFromGroup
QTreeWidgetItem * createItemFromGroup(SymbolNode *node, QTreeWidget *parent)
te::qt::widgets::SymbolSelectorDialog::m_preview
SymbolPreviewWidget * m_preview
Preview Widget used to visualize the symbol.
Definition: SymbolSelectorDialog.h:259
te::qt::widgets::SymbolSelectorDialog::enableGroupItem
void enableGroupItem(bool enable)
te::qt::widgets::SymbolSelectorDialog::buildTree
void buildTree(SymbolNode *node, QTreeWidgetItem *parent)
TEQTWIDGETSEXPORT
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
te::qt::widgets::SymbolSelectorDialog::onHelpPushButtonClicked
void onHelpPushButtonClicked()
te::qt::widgets::SymbolSelectorDialog
A dialog used to create or edit a specific symbol.
Definition: SymbolSelectorDialog.h:74
te::qt::widgets::SymbolSelectorDialog::~SymbolSelectorDialog
virtual ~SymbolSelectorDialog()
Destructor.
te::qt::widgets::SymbolSelectorDialog::getSelectedItemID
QString getSelectedItemID()
te::qt::widgets::SymbolSelectorDialog::updateCurrentSymbol
bool updateCurrentSymbol(Symbol *symbol)
Update the current selected symbol.
te::qt::widgets::SymbolNode
Definition: SymbolNode.h:49
Ui
Definition: ConfigInputAddressDialog.h:44
te::qt::widgets::SymbolSelectorDialog::onOkPushButtonClicked
void onOkPushButtonClicked()
te::qt::widgets::SymbolSelectorDialog::NodeType
NodeType
Auxiliary internal enumeration to control the tree nodes.
Definition: SymbolSelectorDialog.h:85
te::qt::widgets::SymbolSelectorDialog::onEditSymbolPushButtonClicked
void onEditSymbolPushButtonClicked()
te::qt::widgets::SymbolSelectorDialog::m_ui
std::unique_ptr< Ui::SymbolSelectorDialogForm > m_ui
Dialog form.
Definition: SymbolSelectorDialog.h:258
te::qt::widgets::SymbolSelectorDialog::eraseCurrentGroup
bool eraseCurrentGroup()
Remove the current selected symbol from a symbol library.
te::qt::widgets::SymbolSelectorDialog::createItemFromSymbol
QTreeWidgetItem * createItemFromSymbol(Symbol *symbol, QTreeWidgetItem *parent=nullptr)
te::qt::widgets::SymbolSelectorDialog::onClosePushButtonClicked
void onClosePushButtonClicked()
te::qt::widgets::SymbolSelectorDialog::removeSymbol
bool removeSymbol(Symbol *symbol)
Remove a symbol from a symbol library .
te::qt::widgets::SymbolSelectorDialog::createItemFromGroup
QTreeWidgetItem * createItemFromGroup(SymbolNode *node, QTreeWidgetItem *parent=nullptr)
te::qt::widgets::SymbolSelectorDialog::onImportButtonPressed
void onImportButtonPressed()
te::qt::widgets::SymbolSelectorDialog::m_currentDragDropItem
QTreeWidgetItem * m_currentDragDropItem
Definition: SymbolSelectorDialog.h:261
slots
#define slots
Definition: VirtualMachine.h:48
te::qt::widgets::SymbolSelectorDialog::enableSymbolItem
void enableSymbolItem(bool enable)
te::qt::widgets::SymbolSelectorDialog::isRootItem
bool isRootItem(QTreeWidgetItem *item)
te::qt::widgets::SymbolSelectorDialog::onRemoveSymbolPushButtonClicked
void onRemoveSymbolPushButtonClicked()
te::qt::widgets::SymbolSelectorDialog::onRemoveGroupPushButtonClicked
void onRemoveGroupPushButtonClicked()
te::qt::widgets::SymbolSelectorDialog::onShowSymbolInfoPushButtonPressed
void onShowSymbolInfoPushButtonPressed()
te::qt::widgets::SymbolSelectorDialog::getSelectedItem
QTreeWidgetItem * getSelectedItem() const
Get the current selected symbol.
te::qt::widgets::SymbolSelectorDialog::getSymbol
Symbol * getSymbol() const
Gets the selected symbol.
te::qt::widgets::SymbolSelectorDialog::initialize
void initialize()
Initialize the dialog.
te::qt::widgets::SymbolSelectorDialog::formatSymbolInfo
QString formatSymbolInfo(const SymbolInfo &info) const
Auxiliary internal method to format a symbol info to be used on tool tips.
te::qt::widgets::SymbolSelectorDialog::addGroup
bool addGroup(const QString &groupName, const QString &groupParentId)
Add new symbol to a symbol library.
te::qt::widgets::SymbolSelectorDialog::eraseSymbol
bool eraseSymbol(Symbol *symbol)
Remove a symbol from a symbol library .
te::qt::widgets::SymbolSelectorDialog::onDropEvent
void onDropEvent()
te::qt::widgets::SymbolSelectorDialog::getCurrentGroupItem
QTreeWidgetItem * getCurrentGroupItem()
te::qt::widgets::SymbolSelectorDialog::onCreateSymbolPushButtonClicked
void onCreateSymbolPushButtonClicked()
te::qt::widgets::Symbol
This class represents a symbol. TODO: More description!
Definition: Symbol.h:55
te::qt::widgets::SymbolSelectorDialog::onRenameGroupPushButtonClicked
void onRenameGroupPushButtonClicked()
te::qt::widgets::SymbolSelectorDialog::eraseGroup
bool eraseGroup(const QString &groupId)
Remove a symbol from a symbol library .
te::qt::widgets::SymbolSelectorDialog::updateCurrentGroup
bool updateCurrentGroup(const QString &newGroupName, const QString &groupId)
Update the current selected symbol.
te::qt::widgets::SymbolPreviewWidget
A widget used to preview symbol elements.
Definition: SymbolPreviewWidget.h:62
te::qt::widgets::SymbolSelectorDialog::onDragEnterEvent
void onDragEnterEvent()