ctkMenuComboBox_p.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <QWeakPointer>
  19. // CTK includes
  20. #include "ctkMenuComboBox.h"
  21. class ctkCompleter;
  22. class QToolButton;
  23. class ctkMenuComboBoxInternal: public QComboBox
  24. {
  25. Q_OBJECT
  26. public:
  27. /// Superclass typedef
  28. typedef QComboBox Superclass;
  29. ctkMenuComboBoxInternal();
  30. virtual ~ctkMenuComboBoxInternal();
  31. virtual void showPopup();
  32. virtual QSize minimumSizeHint()const;
  33. Q_SIGNALS:
  34. void popupShown();
  35. public:
  36. QWeakPointer<QMenu> Menu;
  37. };
  38. // -------------------------------------------------------------------------
  39. class ctkMenuComboBoxPrivate: public QObject
  40. {
  41. Q_OBJECT
  42. Q_DECLARE_PUBLIC(ctkMenuComboBox);
  43. protected:
  44. ctkMenuComboBox* const q_ptr;
  45. public:
  46. ctkMenuComboBoxPrivate(ctkMenuComboBox& object);
  47. void init();
  48. QAction* actionByTitle(const QString& text, const QMenu* parentMenu);
  49. void setCurrentText(const QString& newCurrentText);
  50. QString currentText()const;
  51. void setCurrentIcon(const QIcon& newCurrentIcon);
  52. QIcon currentIcon()const;
  53. void addAction(QAction* action);
  54. void addMenuToCompleter(QMenu* menu);
  55. void addActionToCompleter(QAction* action);
  56. void removeActionToCompleter(QAction* action);
  57. public Q_SLOTS:
  58. void setComboBoxEditable(bool editable = true);
  59. protected:
  60. QIcon DefaultIcon;
  61. QString DefaultText;
  62. bool IsDefaultTextCurrent;
  63. bool IsDefaultIconCurrent;
  64. ctkMenuComboBox::EditableBehavior EditBehavior;
  65. ctkMenuComboBoxInternal* MenuComboBox;
  66. ctkCompleter* SearchCompleter;
  67. QWeakPointer<QMenu> Menu;
  68. QToolButton* SearchButton;
  69. };
  70. #endif