CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkThumbnailLabel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkThumbnailLabel_h
22 #define __ctkThumbnailLabel_h
23 
24 // Qt includes
25 #include <QWidget>
26 #include <QModelIndex>
27 
28 #include "ctkWidgetsExport.h"
29 
30 class ctkThumbnailLabelPrivate;
31 
38 class CTK_WIDGETS_EXPORT ctkThumbnailLabel : public QWidget
39 {
40  Q_OBJECT
43  Q_PROPERTY(QString text READ text WRITE setText)
48  Q_PROPERTY(Qt::Alignment textPosition READ textPosition WRITE setTextPosition)
51  Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
54  Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode WRITE setTransformationMode)
58  Q_PROPERTY(bool selected READ isSelected WRITE setSelected)
61  Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
62 public:
63  typedef QWidget Superclass;
64  explicit ctkThumbnailLabel(QWidget* parent=0);
65  virtual ~ctkThumbnailLabel();
66 
67  void setText(const QString& text);
68  QString text()const;
69 
70  void setTextPosition(const Qt::Alignment& alignment);
71  Qt::Alignment textPosition()const;
72 
73  void setPixmap(const QPixmap& pixmap);
74  const QPixmap* pixmap()const;
75 
76  Qt::TransformationMode transformationMode()const;
77  void setTransformationMode(Qt::TransformationMode mode);
78 
79  void setSelected(bool selected);
80  bool isSelected()const;
81 
82  void setSelectedColor(const QColor& color);
83  QColor selectedColor()const;
84 
85  virtual QSize minimumSizeHint()const;
86  virtual QSize sizeHint()const;
87  virtual int heightForWidth(int width)const;
88 
89 protected:
90  QScopedPointer<ctkThumbnailLabelPrivate> d_ptr;
91 
92  virtual void paintEvent(QPaintEvent* event);
93  virtual void mousePressEvent(QMouseEvent* event);
94  virtual void mouseDoubleClickEvent(QMouseEvent* event);
95 
96  virtual void resizeEvent(QResizeEvent* event);
97 
98 private:
99  Q_DECLARE_PRIVATE(ctkThumbnailLabel);
100  Q_DISABLE_COPY(ctkThumbnailLabel);
101 
102 Q_SIGNALS:
103  void selected(const ctkThumbnailLabel& widget);
104  void doubleClicked(const ctkThumbnailLabel& widget);
105 };
106 
107 #endif
ctkThumbnailLabel::setSelectedColor
void setSelectedColor(const QColor &color)
ctkThumbnailLabel::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
ctkThumbnailLabel::ctkThumbnailLabel
ctkThumbnailLabel(QWidget *parent=0)
ctkThumbnailLabel::Superclass
QWidget Superclass
Definition: ctkThumbnailLabel.h:63
ctkThumbnailLabel::isSelected
bool isSelected() const
ctkThumbnailLabel::selected
void selected(const ctkThumbnailLabel &widget)
ctkThumbnailLabel::setSelected
void setSelected(bool selected)
ctkThumbnailLabel::setTextPosition
void setTextPosition(const Qt::Alignment &alignment)
ctkThumbnailLabel::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event)
ctkThumbnailLabel::paintEvent
virtual void paintEvent(QPaintEvent *event)
ctkThumbnailLabel::heightForWidth
virtual int heightForWidth(int width) const
ctkThumbnailLabel::setTransformationMode
void setTransformationMode(Qt::TransformationMode mode)
ctkThumbnailLabel::transformationMode
Qt::TransformationMode transformationMode() const
ctkThumbnailLabel::text
QString text() const
ctkThumbnailLabel::sizeHint
virtual QSize sizeHint() const
ctkThumbnailLabel::textPosition
Qt::Alignment textPosition() const
ctkThumbnailLabel::pixmap
const QPixmap * pixmap() const
ctkThumbnailLabel::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QMouseEvent *event)
ctkThumbnailLabel::~ctkThumbnailLabel
virtual ~ctkThumbnailLabel()
ctkThumbnailLabel::doubleClicked
void doubleClicked(const ctkThumbnailLabel &widget)
ctkThumbnailLabel::selectedColor
QColor selectedColor() const
ctkThumbnailLabel::d_ptr
QScopedPointer< ctkThumbnailLabelPrivate > d_ptr
Definition: ctkThumbnailLabel.h:90
ctkThumbnailLabel::setText
void setText(const QString &text)
ctkThumbnailLabel
Definition: ctkThumbnailLabel.h:39
ctkThumbnailLabel::minimumSizeHint
virtual QSize minimumSizeHint() const
ctkThumbnailLabel::setPixmap
void setPixmap(const QPixmap &pixmap)