[kpropertiesdialog] Display item text() when the file is readonly and otherwise would display "." or ""
Needs ReviewPublic

Authored by meven on Oct 25 2019, 9:33 AM.

Details

Reviewers
ngraham
Group Reviewers
Frameworks
Test Plan

Before:

After:

Diff Detail

Repository
R241 KIO
Branch
arcpatch-D24941
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 18158
Build 18176: arc lint + arc unit
meven created this revision.Oct 25 2019, 9:33 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 25 2019, 9:33 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
meven requested review of this revision.Oct 25 2019, 9:33 AM
meven edited the test plan for this revision. (Show Details)Oct 25 2019, 9:36 AM
meven updated this revision to Diff 68736.Oct 25 2019, 9:38 AM

Avoid unncessary change

Do we know why d->oldname is empty or . in the first place? Feels like maybe this should be fixed there.

meven added a comment.Oct 25 2019, 3:51 PM

Do we know why d->oldname is empty or . in the first place? Feels like maybe this should be fixed there.

line 873 in kpropertiesdialog.cpp

// Extract the file name only
filename = properties->defaultName();
if (filename.isEmpty()) {   // no template
    const QFileInfo finfo(item.name());  // this gives support for UDS_NAME, e.g. for kio_trash or kio_system
    filename = finfo.fileName(); // Make sure only the file's name is displayed (#160964).
} else {
    d->m_bFromTemplate = true;
    setDirty(); // to enforce that the copy happens
}
d->oldFileName = filename;
 
// Make it human-readable
filename = nameFromFileName(filename);
 
if (d->bKDesktopMode && d->bDesktopFile) {
    KDesktopFile config(url.toLocalFile());
    if (config.desktopGroup().hasKey("Name")) {
        filename = config.readName();
    }
}
 
d->oldName = filename;

oldName can be from the defaultName passed to the constructor of KPropertiesDialog, QFileInfo.fileName() i.e UDS_NAME ("." by neccessity in case of root of ioslaves) or the Name field of the item desktop file.

I guess you are right this would need some fixing here, the code is convoluted IMO.

You're right that the code is quite convoluted. But it would seem to make sense to fix the value there rather than conditionally overriding it later.