Skip to content

Commit 57542f6

Browse files
authored
Prevent truncating the name of folders upon renaming them (#728)
Fixes #647
1 parent 396a8d1 commit 57542f6

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/elidedlabel.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33
#include <QResizeEvent>
44
#include <QTimer>
55

6-
ElidedLabel::ElidedLabel(QWidget *parent, Qt::WindowFlags f) : QLabel(parent, f)
7-
{
8-
defaultType = Qt::ElideRight;
9-
eliding = false;
10-
original = "";
11-
}
6+
ElidedLabel::ElidedLabel(QWidget *parent, Qt::WindowFlags f) : ElidedLabel("", parent, f) { }
127

138
ElidedLabel::ElidedLabel(const QString &text, QWidget *parent, Qt::WindowFlags f)
14-
: QLabel(text, parent, f)
9+
: QLabel(text, parent, f), original(""), defaultType(Qt::ElideRight), eliding(false)
1510
{
16-
defaultType = Qt::ElideRight;
17-
eliding = false;
1811
setText(text);
1912
}
2013

@@ -24,6 +17,11 @@ void ElidedLabel::setType(const Qt::TextElideMode type)
2417
elide();
2518
}
2619

20+
QString ElidedLabel::text() const
21+
{
22+
return original;
23+
}
24+
2725
void ElidedLabel::resizeEvent(QResizeEvent *event)
2826
{
2927
Q_UNUSED(event);

src/elidedlabel.h

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ElidedLabel : public QLabel
1111
explicit ElidedLabel(const QString &text, QWidget *parent = nullptr,
1212
Qt::WindowFlags f = Qt::WindowFlags());
1313
void setType(const Qt::TextElideMode type);
14+
QString text() const;
1415

1516
public slots:
1617
void setText(const QString &text);

src/foldertreedelegateeditor.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ void FolderTreeDelegateEditor::updateDelegate()
157157
{
158158
auto displayName = m_index.data(NodeItem::Roles::DisplayText).toString();
159159
QFontMetrics fm(m_titleFont);
160-
displayName = fm.elidedText(displayName, Qt::ElideRight, m_label->contentsRect().width());
161160
QString labelStyle;
162161
QString folderIconStyle;
163162

src/labeledittype.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <QBoxLayout>
44
#include <QDebug>
55

6-
LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent)
6+
LabelEditType::LabelEditType(QWidget *parent) : ElidedLabel(parent)
77
{
88
setContentsMargins(0, 0, 0, 0);
99
m_editor = new QLineEdit(this);

src/labeledittype.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef LABELEDITTYPE_H
22
#define LABELEDITTYPE_H
33

4-
#include <QLabel>
4+
#include "elidedlabel.h"
55

66
class QLineEdit;
7-
class LabelEditType : public QLabel
7+
class LabelEditType : public ElidedLabel
88
{
99
Q_OBJECT
1010
public:

0 commit comments

Comments
 (0)