Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Unmaintained
KDE Runtime
Commits
41d645c1
Commit
41d645c1
authored
Dec 14, 2012
by
David Faure
Browse files
Generate nicer-looking display names, no trashId in front (e.g. "0-").
CCBUG: 183403 Doesn't fix the behavior on drag-n-drop though, yet.
parent
79460818
Changes
3
Hide whitespace changes
Inline
Side-by-side
kioslave/trash/kio_trash.cpp
View file @
41d645c1
...
...
@@ -274,7 +274,9 @@ void TrashProtocol::stat(const KUrl& url)
return
;
}
QString
fileName
=
filePath
.
section
(
QLatin1Char
(
'/'
),
-
1
,
-
1
,
QString
::
SectionSkipEmpty
);
// For a toplevel file, use the fileId as display name (to hide the trashId)
// For a file in a subdir, use the fileName as is.
QString
fileDisplayName
=
relativePath
.
isEmpty
()
?
fileId
:
url
.
fileName
();
KUrl
fileURL
;
if
(
url
.
path
().
length
()
>
1
)
{
...
...
@@ -285,7 +287,7 @@ void TrashProtocol::stat(const KUrl& url)
TrashedFileInfo
info
;
ok
=
impl
.
infoForFile
(
trashId
,
fileId
,
info
);
if
(
ok
)
ok
=
createUDSEntry
(
filePath
,
fileName
,
fileURL
.
fileName
(),
entry
,
info
);
ok
=
createUDSEntry
(
filePath
,
file
Display
Name
,
fileURL
.
fileName
(),
entry
,
info
);
if
(
!
ok
)
{
error
(
KIO
::
ERR_COULD_NOT_STAT
,
url
.
prettyUrl
()
);
...
...
@@ -373,7 +375,8 @@ void TrashProtocol::listDir(const KUrl& url)
TrashedFileInfo
infoForItem
(
info
);
infoForItem
.
origPath
+=
QLatin1Char
(
'/'
);
infoForItem
.
origPath
+=
fileName
;
if
(
ok
&&
createUDSEntry
(
filePath
,
fileName
,
fileName
,
entry
,
infoForItem
)
)
{
if
(
createUDSEntry
(
filePath
,
fileName
,
fileName
,
entry
,
infoForItem
))
{
listEntry
(
entry
,
false
);
}
}
...
...
@@ -448,7 +451,8 @@ void TrashProtocol::listRoot()
KUrl
origURL
;
origURL
.
setPath
(
(
*
it
).
origPath
);
entry
.
clear
();
if
(
createUDSEntry
(
(
*
it
).
physicalPath
,
origURL
.
fileName
(),
url
.
fileName
(),
entry
,
*
it
)
)
const
QString
fileDisplayName
=
(
*
it
).
fileId
;
if
(
createUDSEntry
(
(
*
it
).
physicalPath
,
fileDisplayName
,
url
.
fileName
(),
entry
,
*
it
)
)
listEntry
(
entry
,
false
);
}
entry
.
clear
();
...
...
kioslave/trash/tests/testtrash.cpp
View file @
41d645c1
...
...
@@ -1000,6 +1000,7 @@ void TestTrash::listRootDir()
{
m_entryCount
=
0
;
m_listResult
.
clear
();
m_displayNameListResult
.
clear
();
KIO
::
ListJob
*
job
=
KIO
::
listDir
(
KUrl
(
"trash:/"
),
KIO
::
HideProgressInfo
);
connect
(
job
,
SIGNAL
(
entries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
)
),
SLOT
(
slotEntries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
)
)
);
...
...
@@ -1008,14 +1009,18 @@ void TestTrash::listRootDir()
kDebug
()
<<
"listDir done - m_entryCount="
<<
m_entryCount
;
QVERIFY
(
m_entryCount
>
1
);
kDebug
()
<<
m_listResult
;
QVERIFY
(
m_listResult
.
contains
(
"."
)
==
1
);
// found it, and only once
//kDebug() << m_listResult;
//kDebug() << m_displayNameListResult;
QCOMPARE
(
m_listResult
.
count
(
"."
),
1
);
// found it, and only once
QCOMPARE
(
m_displayNameListResult
.
count
(
"fileFromHome"
),
1
);
QCOMPARE
(
m_displayNameListResult
.
count
(
"fileFromHome 1"
),
1
);
}
void
TestTrash
::
listRecursiveRootDir
()
{
m_entryCount
=
0
;
m_listResult
.
clear
();
m_displayNameListResult
.
clear
();
KIO
::
ListJob
*
job
=
KIO
::
listRecursive
(
KUrl
(
"trash:/"
),
KIO
::
HideProgressInfo
);
connect
(
job
,
SIGNAL
(
entries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
)
),
SLOT
(
slotEntries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
)
)
);
...
...
@@ -1024,14 +1029,19 @@ void TestTrash::listRecursiveRootDir()
kDebug
()
<<
"listDir done - m_entryCount="
<<
m_entryCount
;
QVERIFY
(
m_entryCount
>
1
);
kDebug
()
<<
m_listResult
;
QVERIFY
(
m_listResult
.
count
(
"."
)
==
1
);
// found it, and only once
//kDebug() << m_listResult;
//kDebug() << m_displayNameListResult;
QCOMPARE
(
m_listResult
.
count
(
"."
),
1
);
// found it, and only once
QCOMPARE
(
m_displayNameListResult
.
count
(
"fileFromHome"
),
1
);
QCOMPARE
(
m_displayNameListResult
.
count
(
"fileFromHome 1"
),
1
);
QCOMPARE
(
m_displayNameListResult
.
count
(
"testfile_in_subdir"
),
1
);
}
void
TestTrash
::
listSubDir
()
{
m_entryCount
=
0
;
m_listResult
.
clear
();
m_displayNameListResult
.
clear
();
KIO
::
ListJob
*
job
=
KIO
::
listDir
(
KUrl
(
"trash:/0-trashDirFromHome"
),
KIO
::
HideProgressInfo
);
connect
(
job
,
SIGNAL
(
entries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
)
),
SLOT
(
slotEntries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
)
)
);
...
...
@@ -1040,22 +1050,26 @@ void TestTrash::listSubDir()
kDebug
()
<<
"listDir done - m_entryCount="
<<
m_entryCount
;
QVERIFY
(
m_entryCount
==
2
);
kDebug
()
<<
m_listResult
;
QVERIFY
(
m_listResult
.
count
(
"."
)
==
1
);
// found it, and only once
QVERIFY
(
m_listResult
.
count
(
"testfile"
)
==
1
);
// found it, and only once
//kDebug() << m_listResult;
//kDebug() << m_displayNameListResult;
QCOMPARE
(
m_listResult
.
count
(
"."
),
1
);
// found it, and only once
QCOMPARE
(
m_listResult
.
count
(
"testfile"
),
1
);
// found it, and only once
QCOMPARE
(
m_displayNameListResult
.
count
(
"testfile"
),
1
);
}
void
TestTrash
::
slotEntries
(
KIO
::
Job
*
,
const
KIO
::
UDSEntryList
&
lst
)
{
for
(
KIO
::
UDSEntryList
::
ConstIterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
{
const
KIO
::
UDSEntry
&
entry
(
*
it
);
QString
displayName
=
entry
.
stringValue
(
KIO
::
UDSEntry
::
UDS_NAME
);
QString
name
=
entry
.
stringValue
(
KIO
::
UDSEntry
::
UDS_NAME
);
QString
displayName
=
entry
.
stringValue
(
KIO
::
UDSEntry
::
UDS_DISPLAY_NAME
);
KUrl
url
=
entry
.
stringValue
(
KIO
::
UDSEntry
::
UDS_URL
);
kDebug
()
<<
displayName
<<
" "
<<
url
;
kDebug
()
<<
"name"
<<
name
<<
"displayName"
<<
displayName
<<
"
UDS_URL=
"
<<
url
;
if
(
!
url
.
isEmpty
()
)
{
QVERIFY
(
url
.
protocol
()
==
"trash"
);
}
m_listResult
<<
displayName
;
m_listResult
<<
name
;
m_displayNameListResult
<<
displayName
;
}
m_entryCount
+=
lst
.
count
();
}
...
...
kioslave/trash/tests/testtrash.h
View file @
41d645c1
...
...
@@ -116,6 +116,7 @@ private:
int
m_entryCount
;
QStringList
m_listResult
;
QStringList
m_displayNameListResult
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment