Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the issue where the original name of a node would be truncated when the name was too long. #728

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/elidedlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
#include <QResizeEvent>
#include <QTimer>

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);
}

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/elidedlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/foldertreedelegateeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/labeledittype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <QBoxLayout>
#include <QDebug>

LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent)
LabelEditType::LabelEditType(QWidget *parent) : ElidedLabel(parent)
{
setContentsMargins(0, 0, 0, 0);
m_editor = new QLineEdit(this);
Expand Down
4 changes: 2 additions & 2 deletions src/labeledittype.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef LABELEDITTYPE_H
#define LABELEDITTYPE_H

#include <QLabel>
#include "elidedlabel.h"

class QLineEdit;
class LabelEditType : public QLabel
class LabelEditType : public ElidedLabel
{
Q_OBJECT
public:
Expand Down