diff --git a/src/elidedlabel.cpp b/src/elidedlabel.cpp index 4f504a0c..231a1445 100644 --- a/src/elidedlabel.cpp +++ b/src/elidedlabel.cpp @@ -3,18 +3,11 @@ #include #include -ElidedLabel::ElidedLabel(QWidget *parent, Qt::WindowFlags f) : QLabel(parent, f) -{ - defaultType = Qt::ElideRight; - eliding = false; - original = ""; -} +ElidedLabel::ElidedLabel(QWidget *parent, Qt::WindowFlags f) : ElidedLabel("", parent, f) { } ElidedLabel::ElidedLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) - : QLabel(text, parent, f) + : QLabel(text, parent, f), original(""), defaultType(Qt::ElideRight), eliding(false) { - defaultType = Qt::ElideRight; - eliding = false; setText(text); } @@ -24,6 +17,11 @@ void ElidedLabel::setType(const Qt::TextElideMode type) elide(); } +QString ElidedLabel::text() const +{ + return original; +} + void ElidedLabel::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); diff --git a/src/elidedlabel.h b/src/elidedlabel.h index 8c1bd5fd..d2ed2a16 100644 --- a/src/elidedlabel.h +++ b/src/elidedlabel.h @@ -11,6 +11,7 @@ class ElidedLabel : public QLabel explicit ElidedLabel(const QString &text, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); void setType(const Qt::TextElideMode type); + QString text() const; public slots: void setText(const QString &text); diff --git a/src/foldertreedelegateeditor.cpp b/src/foldertreedelegateeditor.cpp index 5c46b695..a39eb667 100644 --- a/src/foldertreedelegateeditor.cpp +++ b/src/foldertreedelegateeditor.cpp @@ -157,7 +157,6 @@ void FolderTreeDelegateEditor::updateDelegate() { auto displayName = m_index.data(NodeItem::Roles::DisplayText).toString(); QFontMetrics fm(m_titleFont); - displayName = fm.elidedText(displayName, Qt::ElideRight, m_label->contentsRect().width()); QString labelStyle; QString folderIconStyle; diff --git a/src/labeledittype.cpp b/src/labeledittype.cpp index 229f0a98..e5114914 100644 --- a/src/labeledittype.cpp +++ b/src/labeledittype.cpp @@ -3,7 +3,7 @@ #include #include -LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent) +LabelEditType::LabelEditType(QWidget *parent) : ElidedLabel(parent) { setContentsMargins(0, 0, 0, 0); m_editor = new QLineEdit(this); diff --git a/src/labeledittype.h b/src/labeledittype.h index b3816170..485a24a5 100644 --- a/src/labeledittype.h +++ b/src/labeledittype.h @@ -1,10 +1,10 @@ #ifndef LABELEDITTYPE_H #define LABELEDITTYPE_H -#include +#include "elidedlabel.h" class QLineEdit; -class LabelEditType : public QLabel +class LabelEditType : public ElidedLabel { Q_OBJECT public: