CSelectionParamGuiComp.h
Go to the documentation of this file.
1 #ifndef iqtprm_CSelectionParamGuiComp_included
2 #define iqtprm_CSelectionParamGuiComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QtGlobal>
7 #include <QtGui/QStandardItemModel>
8 #if QT_VERSION >= 0x050000
9 #include <QtCore/QSortFilterProxyModel>
10 #include <QtWidgets/QLineEdit>
11 #include <QtWidgets/QComboBox>
12 #include <QtWidgets/QRadioButton>
13 #include <QtWidgets/QPushButton>
14 #include <QtWidgets/QCompleter>
15 #else
16 #include <QtGui/QSortFilterProxyModel>
17 #include <QtGui/QLineEdit>
18 #include <QtGui/QComboBox>
19 #include <QtGui/QRadioButton>
20 #include <QtGui/QPushButton>
21 #include <QtGui/QCompleter>
22 #endif
23 
24 
25 // ACF includes
26 #include <istd/TPointerVector.h>
27 
29 #include <iprm/ISelectionParam.h>
30 #include <iqtgui/IIconProvider.h>
32 #include <GeneratedFiles/iqtprm/ui_CSelectionParamGuiComp.h>
33 
34 
35 namespace iqtprm
36 {
37 
43  Ui::CSelectionParamGuiComp, iprm::ISelectionParam>,
45 {
46  Q_OBJECT
47 
48 public:
50  Ui::CSelectionParamGuiComp, iprm::ISelectionParam> BaseClass;
51 
55  enum UiMode
56  {
61 
66 
71  };
72 
77  {
82 
87  };
88 
90  {
94  };
95 
96  I_BEGIN_COMPONENT(CSelectionParamGuiComp);
97  I_ASSIGN(m_optionsLabelAttrPtr, "OptionsLabel", "Command label for the options selector", false, "Select");
98  I_ASSIGN(m_infoLabelAttrPtr, "InfoLabel", "Information label for the options selector", false, "Info");
99  I_ASSIGN(m_infoIconProviderCompPtr, "InfoIconProvider", "Provider of the info icon", false, "InfoIconProvider");
100  I_ASSIGN(m_iconSizeAttrPtr, "IconSize", "Size of the used icons", false, 32);
101  I_ASSIGN(m_uiModeAttrPtr, "UiMode", "Selection representation mode.\n0 - Combo box\n1 - Horizontally layouted radio button group\n2 - Vertically layouted radio button group", true, UM_COMBOBOX);
102  I_ASSIGN(m_labelPositionAttrPtr, "LabelPosition", "Selection label position.\n0 - Left from the selector,\n1 - On top of the selector", false, LP_LEFT);
103  I_ASSIGN(m_labelAlignAttrPtr, "LabelAlignment", "Selection label alignment.\n0 - Left-Top,\n1 - Center-Top,\n2 - Right-Top,\n3 - Left-Center,\n4 - Center,\n5 - Right-Center,\n6 - Left-Bottom,\n7 - Center-Bottom,\n8 - Right-Bottom", false, LA_LEFT_CENTER);
104  I_ASSIGN(m_labelWidthAttrPtr, "LabelWidth", "Fixed label width (in pixels)", false, 100);
105  I_ASSIGN(m_disableWhenEmptyAttrPtr, "DisableWhenEmpty", "Disable the control when no Option is available", true, false);
106  I_ASSIGN(m_noSelectionAllowedAttrPtr, "NoSelectionAllowed", "Allow the control to reset current index (i.e. set to -1)", true, false);
107  I_ASSIGN(m_fillWithDisabledOptionsEnabledAttrPtr, "FillWithDisabledOptionsEnabled", "Fill combo box also with disabled options, if enabled", true, false);
108  I_ASSIGN(m_useCompleterAttrPtr, "UseCompleter", "Enable completer for combo box", true, false);
109  I_END_COMPONENT;
110 
112 
113 protected:
114  // reimplemented (iqtgui::TGuiObserverWrap)
115  virtual void OnGuiModelAttached();
116  virtual void OnGuiModelDetached();
117  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
118 
119  // reimplemented (iqtgui::CGuiComponentBase)
120  virtual void OnGuiCreated();
121  virtual void OnGuiDestroyed();
122  virtual void OnGuiShown();
123  virtual void OnGuiRetranslate();
124 
125  // reimplemented (imod::CMultiModelDispatcherBase)
126  virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet& changeSet);
127 
128 protected Q_SLOTS:
129  void OnSelectionChanged(int index);
130  void OnRadioButtonSelectionChanged(bool isSelected);
131  void OnResetButtonClicked();
132  void OnFilterTextEdited(const QString& text);
133 
134 private:
135  void UpdateComboBoxesView();
136  void UpdateRadioButtonView();
137  void UpdateDescriptionFrame();
138  void UpdateSelectorLabel();
139  void ResetWidgets();
140  iprm::ISelectionParam* GetActiveSubselection(const iprm::ISelectionParam* selectionPtr) const;
141  void SetupInfoLabelIcon(QLabel& label);
142  QPixmap GetInfoIcon() const;
143  void UpdateCompletionModel();
144 
145 private:
146  I_TEXTATTR(m_optionsLabelAttrPtr);
147  I_TEXTATTR(m_infoLabelAttrPtr);
148  I_ATTR(int, m_uiModeAttrPtr);
149  I_ATTR(int, m_labelPositionAttrPtr);
150  I_ATTR(int, m_labelAlignAttrPtr);
151  I_ATTR(int, m_labelWidthAttrPtr);
152  I_REF(iqtgui::IIconProvider, m_infoIconProviderCompPtr);
153  I_ATTR(int, m_iconSizeAttrPtr);
154  I_ATTR(bool, m_disableWhenEmptyAttrPtr);
155  I_ATTR(bool, m_noSelectionAllowedAttrPtr);
156  I_ATTR(bool, m_fillWithDisabledOptionsEnabledAttrPtr);
157  I_ATTR(bool, m_useCompleterAttrPtr);
158 
159  class RadioButtonWidget: public QFrame
160  {
161  public:
162  typedef QFrame BaseClass;
163 
164  RadioButtonWidget(
165  const QPixmap& infoIcon,
166  const QString& optionName,
167  const QString& optionDescription,
168  QButtonGroup* buttonGroupPtr,
169  QWidget& parentFrame);
170 
171  QRadioButton* GetRadioButton() const;
172 
173  private:
174  QRadioButton* m_radioButtonPtr;
175  QButtonGroup* m_buttonGroupPtr;
176  };
177 
178  istd::TDelPtr<QLabel> m_selectorLabelPtr;
179  istd::TPointerVector<QComboBox> m_comboBoxes;
181  istd::TPointerVector<QButtonGroup> m_radioButtonGroups;
182  istd::TDelPtr<QFrame> m_radioButtonFramePtr;
183  QPushButton* m_resetButtonWidgetPtr;
184 
185  QStandardItemModel m_completionModel;
186 };
187 
188 
189 } // namespace iqtprm
190 
191 
192 #endif // !iqtprm_CSelectionParamGuiComp_included
193 
194 
virtual void OnGuiModelAttached()
Called when model is attached and GUI is created.
This interface provides acces to an icon.
Definition: IIconProvider.h:21
Generic implementation of a data model changes notifier.
virtual void OnGuiRetranslate()
Called from widget event filter when GUI should be retranslated.
Simple editor for an exclusive option selection.
virtual void OnGuiModelDetached()
Called when model is detached or GUI is destroyed.
virtual void OnGuiDestroyed()
Called just before GUI is released.
void OnSelectionChanged(int index)
void OnFilterTextEdited(const QString &text)
Base class for all Qt GUI components.
iqtgui::TDesignerGuiObserverCompBase< Ui::CSelectionParamGuiComp, iprm::ISelectionParam > BaseClass
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
Do update of the GUI to reflect the state of model.
UiMode
GUI mode for selection representation.
void OnRadioButtonSelectionChanged(bool isSelected)
virtual void OnGuiShown()
Called from widget event filter when slave widget is shown.
Set of change flags (its IDs).
Definition: IChangeable.h:30
Interface allowing to select single option from list of options.
virtual void OnModelChanged(int modelId, const istd::IChangeable::ChangeSet &changeSet)
LabelPosition
Command label position.
virtual void OnGuiCreated()
Called just after GUI is initialized.

© 2007-2017 Witold Gantzke and Kirill Lepskiy