ctkThumbnailWidget.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.commontk.org/LICENSE
  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. Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
  26. Q_PROPERTY(bool selected READ isSelected WRITE setSelected)
  27. public:
  28. typedef QWidget Superclass;
  29. explicit ctkThumbnailWidget(QWidget* parent=0);
  30. virtual ~ctkThumbnailWidget();
  31. void setText(const QString& text);
  32. QString text()const;
  33. void setPixmap(const QPixmap& pixmap);
  34. const QPixmap* pixmap()const;
  35. void setSelected(bool selected);
  36. bool isSelected();
  37. protected:
  38. QScopedPointer<ctkThumbnailWidgetPrivate> d_ptr;
  39. virtual void mousePressEvent(QMouseEvent* event);
  40. virtual void mouseDoubleClickEvent(QMouseEvent* event);
  41. virtual void resizeEvent(QResizeEvent* event);
  42. private:
  43. Q_DECLARE_PRIVATE(ctkThumbnailWidget);
  44. Q_DISABLE_COPY(ctkThumbnailWidget);
  45. signals:
  46. void selected(const ctkThumbnailWidget& widget);
  47. void doubleClicked(const ctkThumbnailWidget& widget);
  48. };
  49. #endif