File indexing completed on 2025-03-09 04:45:07
0001 /* 0002 SPDX-FileCopyrightText: 2000, 2001, 2003 Cornelius Schumacher <schumacher@kde.org> 0003 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0006 */ 0007 #pragma once 0008 0009 #include <QLabel> 0010 0011 namespace EventViews 0012 { 0013 class AlternateLabel : public QLabel 0014 { 0015 Q_OBJECT 0016 public: 0017 AlternateLabel(const QString &shortlabel, const QString &longlabel, const QString &extensivelabel = QString(), QWidget *parent = nullptr); 0018 ~AlternateLabel() override; 0019 0020 enum TextType { Short = 0, Long = 1, Extensive = 2 }; 0021 0022 [[nodiscard]] TextType largestFittingTextType() const; 0023 void setFixedType(TextType type); 0024 0025 public Q_SLOTS: 0026 void useShortText(); 0027 void useLongText(); 0028 void useExtensiveText(); 0029 void useDefaultText(); 0030 0031 protected: 0032 void resizeEvent(QResizeEvent *) override; 0033 virtual void squeezeTextToLabel(); 0034 bool mTextTypeFixed = false; 0035 const QString mShortText; 0036 const QString mLongText; 0037 QString mExtensiveText; 0038 0039 private: 0040 int getIndent() const; 0041 }; 0042 }