File indexing completed on 2024-11-24 04:41:33
0001 /* 0002 SPDX-FileCopyrightText: 2000, 2001, 2003 Cornelius Schumacher <schumacher@kde.org> 0003 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 0004 SPDX-FileCopyrightText: 2007 Loïc Corbasson <loic.corbasson@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0007 */ 0008 #pragma once 0009 0010 #include "calendardecoration.h" 0011 0012 #include <QLabel> 0013 0014 namespace EventViews 0015 { 0016 class DecorationLabel : public QLabel 0017 { 0018 Q_OBJECT 0019 public: 0020 explicit DecorationLabel(EventViews::CalendarDecoration::Element *e, QWidget *parent = nullptr); 0021 0022 explicit DecorationLabel(const QString &shortText, 0023 const QString &longText = QString(), 0024 const QString &extensiveText = QString(), 0025 const QPixmap &pixmap = QPixmap(), 0026 const QUrl &url = QUrl(), 0027 QWidget *parent = nullptr); 0028 ~DecorationLabel() override; 0029 0030 public Q_SLOTS: 0031 void setExtensiveText(const QString &); 0032 void setLongText(const QString &); 0033 void setPixmap(const QPixmap &); 0034 void setShortText(const QString &); 0035 void setText(const QString &); 0036 void setUrl(const QUrl &); 0037 void useShortText(bool allowAutomaticSqueeze = false); 0038 void useLongText(bool allowAutomaticSqueeze = false); 0039 void useExtensiveText(bool allowAutomaticSqueeze = false); 0040 void usePixmap(bool allowAutomaticSqueeze = false); 0041 void useDefaultText(); 0042 0043 protected: 0044 void resizeEvent(QResizeEvent *) override; 0045 void mouseReleaseEvent(QMouseEvent *) override; 0046 virtual void squeezeContentsToLabel(); 0047 bool mAutomaticSqueeze = true; 0048 EventViews::CalendarDecoration::Element *mDecorationElement = nullptr; 0049 QString mShortText; 0050 QString mLongText; 0051 QString mExtensiveText; 0052 QPixmap mPixmap; 0053 QUrl mUrl; 0054 }; 0055 }