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 
35 // STL
36 #include <memory>
37 
38 // Forward declaraion
39 class QTreeWidgetItem;
40 namespace Ui { class SymbolSelectorDialogForm; }
41 
42 namespace te
43 {
44  namespace qt
45  {
46  namespace widgets
47  {
48 // Forward declarations
49  class Symbol;
50  struct SymbolInfo;
51  class SymbolPreviewWidget;
52 
53  /*!
54  \class SymbolSelectorDialog
55 
56  \brief A dialog used to select a specific symbol.
57  */
58  class TEQTWIDGETSEXPORT SymbolSelectorDialog : public QDialog
59  {
60  Q_OBJECT
61 
62  private:
63 
64  /*!
65  \enum NodeType
66 
67  \brief Auxiliary internal enumeration to control the tree nodes.
68  */
69  enum NodeType
70  {
71  LIBRARY = 0, /*!< Library root node. */
72  SYMBOL = 1 /*!< Symbol node. */
73  };
74 
75  public:
76 
77  /** @name Initializer Methods
78  * Methods related to instantiation and destruction.
79  */
80  //@{
81 
82  /*! \brief Constructs a symbol selector dialog which is a child of parent, with widget flags set to f. */
83  SymbolSelectorDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
84 
85  /*! \brief Destructor. */
87 
88  //@}
89 
90  /*!
91  \brief Pops up a modal symbol selector dialog with the given window title, lets the user select a symbol,
92  and returns that symbol.
93 
94  \param parent Dialog parent.
95  \param title Dialog title.
96 
97  \note The caller will take the ownership of the returned symbol.
98  \note It returns a NULL pointr if the user cancels the dialog.
99  \note It return a NULL pointer if there is not a selected symbol.
100  */
101  static Symbol* getSymbol(QWidget* parent, const QString& title = "");
102 
103  /*!
104  \brief Gets the selected symbol.
105 
106  \return The selected fill element.
107 
108  \note The caller will take the ownership of the returned symbol.
109  \note It return a NULL pointer if there is not a selected symbol.
110  */
111  Symbol* getSymbol() const;
112 
113  private slots:
114 
115  void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
116 
117  void onShowSymbolInfoPushButtonPressed();
118 
119  void onLoadSymbolLibraryPushButtonPressed();
120 
121  void onSearchLineEditTextChanged(const QString& text);
122 
123  private:
124 
125  /*! \brief Initialize the dialog. */
126  void initialize();
127 
128  /*! \brief Auxiliary internal method to filter the symbols. */
129  void filter(const QList<QTreeWidgetItem*>& items);
130 
131  /*! \brief Auxiliary internal method that returns the selected symbol. */
132  Symbol* getSelectedSymbol() const;
133 
134  /*! \brief Auxiliary internal method that returns the symbol given a list widget item. */
135  Symbol* getSymbolFromItem(QTreeWidgetItem* item) const;
136 
137  /*! \brief Auxiliary internal method to format a symbol info to be used on tool tips. */
138  QString formatSymbolInfo(const SymbolInfo& info) const;
139 
140  private:
141 
142  std::auto_ptr<Ui::SymbolSelectorDialogForm> m_ui; //!< Dialog form.
143  SymbolPreviewWidget* m_preview; //!< Preview Widget used to visualize the symbol.
144  };
145 
146  } // end namespace widgets
147  } // end namespace qt
148 } // end namespace te
149 
150 #endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_SYMBOLSELECTORDIALOG_H
std::auto_ptr< Ui::SymbolSelectorDialogForm > m_ui
Dialog form.
URI C++ Library.
Information about a given Symbol.
Definition: SymbolInfo.h:60
This class represents a symbol. TODO: More description!
Definition: Symbol.h:54
A dialog used to select a specific symbol.
A widget used to preview symbol elements.
SymbolPreviewWidget * m_preview
Preview Widget used to visualize the symbol.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
NodeType
Auxiliary internal enumeration to control the tree nodes.