ctkThumbnailWidget.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. Q_PROPERTY(bool selected READ isSelected WRITE setSelected)
  30. Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
  31. public:
  32. typedef QWidget Superclass;
  33. explicit ctkThumbnailWidget(QWidget* parent=0);
  34. virtual ~ctkThumbnailWidget();
  35. void setText(const QString& text);
  36. QString text()const;
  37. void setTextPosition(const Qt::Alignment& alignment);
  38. Qt::Alignment textPosition()const;
  39. void setPixmap(const QPixmap& pixmap);
  40. const QPixmap* pixmap()const;
  41. void setSelected(bool selected);
  42. bool isSelected()const;
  43. void setSelectedColor(const QColor& color);
  44. QColor selectedColor()const;
  45. protected:
  46. QScopedPointer<ctkThumbnailWidgetPrivate> d_ptr;
  47. virtual void mousePressEvent(QMouseEvent* event);
  48. virtual void mouseDoubleClickEvent(QMouseEvent* event);
  49. virtual void resizeEvent(QResizeEvent* event);
  50. private:
  51. Q_DECLARE_PRIVATE(ctkThumbnailWidget);
  52. Q_DISABLE_COPY(ctkThumbnailWidget);
  53. signals:
  54. void selected(const ctkThumbnailWidget& widget);
  55. void doubleClicked(const ctkThumbnailWidget& widget);
  56. };
  57. #endif