Changeset View
Changeset View
Standalone View
Standalone View
src/ksqueezedtextlabel.h
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | * label->setText("new text"); // this will not work | 54 | * label->setText("new text"); // this will not work | ||
55 | * squeezed->setText("new text"); // works as expected | 55 | * squeezed->setText("new text"); // works as expected | ||
56 | * static_cast<KSqueezedTextLabel*>(label)->setText("new text"); // works as expected | 56 | * static_cast<KSqueezedTextLabel*>(label)->setText("new text"); // works as expected | ||
57 | * \endcode | 57 | * \endcode | ||
58 | * | 58 | * | ||
59 | * @author Ronny Standtke <Ronny.Standtke@gmx.de> | 59 | * @author Ronny Standtke <Ronny.Standtke@gmx.de> | ||
60 | */ | 60 | */ | ||
61 | 61 | | |||
62 | // TODO KF6: | ||||
63 | // - make more functions virtual (to benefit subclasses of KSqueezedTextLabel) | ||||
64 | // - try to eliminate need for non-virtual-warning (to benefit use as QLabel), | ||||
65 | // see https://phabricator.kde.org/D7164 for some ideas/considerations | ||||
66 | | ||||
62 | /* | 67 | /* | ||
63 | * QLabel | 68 | * QLabel | ||
64 | */ | 69 | */ | ||
65 | class KWIDGETSADDONS_EXPORT KSqueezedTextLabel : public QLabel | 70 | class KWIDGETSADDONS_EXPORT KSqueezedTextLabel : public QLabel | ||
66 | { | 71 | { | ||
67 | Q_OBJECT | 72 | Q_OBJECT | ||
68 | Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode) | 73 | Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode) | ||
69 | 74 | | |||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 75 | public: | |||
122 | * @returns true if the text displayed is currently squeezed, | 127 | * @returns true if the text displayed is currently squeezed, | ||
123 | * i.e. the original text does not fit inside the space available | 128 | * i.e. the original text does not fit inside the space available | ||
124 | * and elide mode is set to a value other than Qt::ElideNone. | 129 | * and elide mode is set to a value other than Qt::ElideNone. | ||
125 | * | 130 | * | ||
126 | * @since 5.38 | 131 | * @since 5.38 | ||
127 | */ | 132 | */ | ||
128 | bool isSqueezed() const; | 133 | bool isSqueezed() const; | ||
129 | 134 | | |||
135 | /** | ||||
136 | * @return the rectangle to squeeze the text into | ||||
137 | * | ||||
138 | * Reimplementation of QLabel::contentsRect(). | ||||
139 | * | ||||
140 | * @warning The corresponding function in the base class is not virtual. | ||||
141 | * Therefore make sure to call this function on objects of type KSqueezedTextLabel, | ||||
142 | * as shown in the @ref non-virtual-warning "example in the class description". | ||||
143 | * | ||||
144 | * @since 5.39 | ||||
145 | */ | ||||
146 | QRect contentsRect() const; | ||||
147 | | ||||
130 | public Q_SLOTS: | 148 | public Q_SLOTS: | ||
131 | /** | 149 | /** | ||
132 | * Sets the text. | 150 | * Sets the text. | ||
133 | * @param text The new text. | 151 | * @param text The new text. | ||
134 | * | 152 | * | ||
135 | * Reimplementation of QLabel::setText(). | 153 | * Reimplementation of QLabel::setText(). | ||
136 | * | 154 | * | ||
137 | * @warning The corresponding function in the base class is not virtual. | 155 | * @warning The corresponding function in the base class is not virtual. | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |