ctkThumbnailWidget.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 __ctkThumbnailWidget_h
  15. #define __ctkThumbnailWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. #include <QModelIndex>
  19. #include "ctkWidgetsExport.h"
  20. class ctkThumbnailWidgetPrivate;
  21. class CTK_WIDGETS_EXPORT ctkThumbnailWidget : public QWidget
  22. {
  23. Q_OBJECT
  24. Q_PROPERTY(QString text READ text WRITE setText)
  25. /// Position of the text relative to the pixmap.
  26. /// Qt::AlignTop | Qt::AlignHCenter by default.
  27. Q_PROPERTY(Qt::Alignment textPosition READ textPosition WRITE setTextPosition)
  28. Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
  29. /// Qt::FastTransformation by default
  30. Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode WRITE setTransformationMode)
  31. /// Not selected by default
  32. Q_PROPERTY(bool selected READ isSelected WRITE setSelected)
  33. /// Palette highlight color by default
  34. Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
  35. public:
  36. typedef QWidget Superclass;
  37. explicit ctkThumbnailWidget(QWidget* parent=0);
  38. virtual ~ctkThumbnailWidget();
  39. void setText(const QString& text);
  40. QString text()const;
  41. void setTextPosition(const Qt::Alignment& alignment);
  42. Qt::Alignment textPosition()const;
  43. void setPixmap(const QPixmap& pixmap);
  44. const QPixmap* pixmap()const;
  45. Qt::TransformationMode transformationMode()const;
  46. void setTransformationMode(Qt::TransformationMode mode);
  47. void setSelected(bool selected);
  48. bool isSelected()const;
  49. void setSelectedColor(const QColor& color);
  50. QColor selectedColor()const;
  51. protected:
  52. QScopedPointer<ctkThumbnailWidgetPrivate> d_ptr;
  53. virtual void mousePressEvent(QMouseEvent* event);
  54. virtual void mouseDoubleClickEvent(QMouseEvent* event);
  55. virtual void resizeEvent(QResizeEvent* event);
  56. private:
  57. Q_DECLARE_PRIVATE(ctkThumbnailWidget);
  58. Q_DISABLE_COPY(ctkThumbnailWidget);
  59. signals:
  60. void selected(const ctkThumbnailWidget& widget);
  61. void doubleClicked(const ctkThumbnailWidget& widget);
  62. };
  63. #endif