ctkMenuComboBox_p.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkMenuComboBox_p_h
  15. #define __ctkMenuComboBox_p_h
  16. // Qt includes
  17. #include <QComboBox>
  18. #include <QPointer>
  19. // CTK includes
  20. #include "ctkMenuComboBox.h"
  21. class ctkCompleter;
  22. class QToolButton;
  23. /// \ingroup Widgets
  24. class ctkMenuComboBoxInternal: public QComboBox
  25. {
  26. Q_OBJECT
  27. public:
  28. /// Superclass typedef
  29. typedef QComboBox Superclass;
  30. ctkMenuComboBoxInternal();
  31. virtual ~ctkMenuComboBoxInternal();
  32. virtual void showPopup();
  33. virtual QSize minimumSizeHint()const;
  34. Q_SIGNALS:
  35. void popupShown();
  36. public:
  37. QPointer<QMenu> Menu;
  38. };
  39. // -------------------------------------------------------------------------
  40. /// \ingroup Widgets
  41. class ctkMenuComboBoxPrivate: public QObject
  42. {
  43. Q_OBJECT
  44. Q_DECLARE_PUBLIC(ctkMenuComboBox);
  45. protected:
  46. ctkMenuComboBox* const q_ptr;
  47. public:
  48. ctkMenuComboBoxPrivate(ctkMenuComboBox& object);
  49. void init();
  50. QAction* actionByTitle(const QString& text, const QMenu* parentMenu);
  51. void setCurrentText(const QString& newCurrentText);
  52. QString currentText()const;
  53. void setCurrentIcon(const QIcon& newCurrentIcon);
  54. QIcon currentIcon()const;
  55. void addAction(QAction* action);
  56. void addMenuToCompleter(QMenu* menu);
  57. void addActionToCompleter(QAction* action);
  58. void removeActionToCompleter(QAction* action);
  59. public Q_SLOTS:
  60. void setComboBoxEditable(bool editable = true);
  61. void onCompletion(const QString& text);
  62. protected:
  63. QIcon DefaultIcon;
  64. QString DefaultText;
  65. bool IsDefaultTextCurrent;
  66. bool IsDefaultIconCurrent;
  67. ctkMenuComboBox::EditableBehavior EditBehavior;
  68. ctkMenuComboBoxInternal* MenuComboBox;
  69. ctkCompleter* SearchCompleter;
  70. QPointer<QMenu> Menu;
  71. QToolButton* SearchButton;
  72. };
  73. #endif