ctkThumbnailListWidget.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 __ctkThumbnailListWidget_h
  15. #define __ctkThumbnailListWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. class QResizeEvent;
  19. // CTK includes
  20. #include "ctkWidgetsExport.h"
  21. class ctkThumbnailListWidgetPrivate;
  22. class ctkThumbnailLabel;
  23. /// \ingroup Widgets
  24. class CTK_WIDGETS_EXPORT ctkThumbnailListWidget : public QWidget
  25. {
  26. Q_OBJECT
  27. Q_PROPERTY(int currentThumbnail READ currentThumbnail WRITE setCurrentThumbnail)
  28. Q_PROPERTY(Qt::Orientation flow READ flow WRITE setFlow)
  29. Q_PROPERTY(QSize thumbnailSize READ thumbnailSize WRITE setThumbnailSize)
  30. public:
  31. typedef QWidget Superclass;
  32. explicit ctkThumbnailListWidget(QWidget* parent=0);
  33. virtual ~ctkThumbnailListWidget();
  34. /// Add multiple thumbnails to the widget
  35. void addThumbnails(QList<QPixmap> thumbnails);
  36. /// Set current thumbnail
  37. void setCurrentThumbnail(int index);
  38. /// Get current thumbnail
  39. int currentThumbnail();
  40. /// Clear all the thumbnails
  41. void clearThumbnails();
  42. /// Flow of the layout
  43. /// - Qt::Horizontal: left to right
  44. /// - Qt::Vertical: top to bottom
  45. void setFlow(Qt::Orientation orientation);
  46. Qt::Orientation flow()const;
  47. /// Get thumbnail width
  48. QSize thumbnailSize()const;
  49. public Q_SLOTS:
  50. /// Set thumbnail width
  51. void setThumbnailSize(QSize size);
  52. Q_SIGNALS:
  53. void selected(const ctkThumbnailLabel& widget);
  54. void doubleClicked(const ctkThumbnailLabel& widget);
  55. protected Q_SLOTS:
  56. void onThumbnailSelected(const ctkThumbnailLabel& widget);
  57. protected:
  58. explicit ctkThumbnailListWidget(ctkThumbnailListWidgetPrivate* ptr, QWidget* parent=0);
  59. ctkThumbnailListWidgetPrivate* d_ptr;
  60. virtual void resizeEvent(QResizeEvent* event);
  61. private:
  62. Q_DECLARE_PRIVATE(ctkThumbnailListWidget);
  63. Q_DISABLE_COPY(ctkThumbnailListWidget);
  64. };
  65. #endif