kio: drop redundant KFileItem constructors and arguments

never set to anything other than empty QString or KFileItem::Unknown

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-27 18:26:44 +03:00
parent b2a8af5dd6
commit edbdb6dfbe
6 changed files with 17 additions and 50 deletions

View file

@ -34,7 +34,7 @@ static KIO::PreviewJob* createJob(const KUrl &url, int w, int h)
{
if (url.isValid()) {
KFileItemList items;
items.append(KFileItem(KFileItem::Unknown, KFileItem::Unknown, url));
items.append(KFileItem(url));
static const QStringList plugins = KIO::PreviewJob::availablePlugins();
KIO::PreviewJob *previewJob = KIO::filePreview(items, QSize(w, h), &plugins);

View file

@ -517,7 +517,7 @@ void KNewFileMenuPrivate::executeStrategy()
if (uSrc.isLocalFile()) {
// In case the templates/.source directory contains symlinks, resolve
// them to the target files. Fixes bug #149628.
KFileItem item(uSrc, QString(), KFileItem::Unknown);
KFileItem item(uSrc);
if (item.isLink())
uSrc.setPath(item.linkDest());

View file

@ -342,7 +342,7 @@ KPropertiesDialog::KPropertiesDialog(const KUrl &tempUrl, const KUrl &currentDir
Q_ASSERT(!d->m_singleUrl.isEmpty());
// Create the KFileItem for the _template_ file, in order to read from it.
d->m_items.append(KFileItem(KFileItem::Unknown, KFileItem::Unknown, d->m_singleUrl));
d->m_items.append(KFileItem(d->m_singleUrl));
d->init();
}

View file

@ -65,22 +65,16 @@ class KFileItemPrivate : public QSharedData
{
public:
KFileItemPrivate(const KIO::UDSEntry &entry,
mode_t mode, mode_t permissions,
const KUrl &itemOrDirUrl,
bool urlIsDirectory)
: m_entry(entry),
m_url(itemOrDirUrl),
m_strName(),
m_strText(),
m_iconName(),
m_strLowerCaseName(),
m_pMimeType(nullptr),
m_fileMode(mode),
m_permissions(permissions),
m_fileMode(KFileItem::Unknown),
m_permissions(KFileItem::Unknown),
m_bMarked(false),
m_bLink(false),
m_bIsLocalUrl(itemOrDirUrl.isLocalFile()),
m_slow(SlowUnknown)
m_bIsLocalUrl(itemOrDirUrl.isLocalFile())
{
if (entry.count() != 0) {
// extract fields from the KIO::UDS Entry
@ -193,9 +187,6 @@ public:
*/
bool m_bIsLocalUrl;
// Slow? (nfs/smb/ssh)
mutable enum { SlowUnknown, Fast, Slow } m_slow;
// For special case like link to dirs over FTP
QString m_guessedMimeType;
@ -299,24 +290,16 @@ KFileItem::KFileItem()
{
}
KFileItem::KFileItem(const KIO::UDSEntry& entry, const KUrl& itemOrDirUrl)
: d(new KFileItemPrivate(entry, KFileItem::Unknown, KFileItem::Unknown, itemOrDirUrl, true))
KFileItem::KFileItem(const KIO::UDSEntry& entry, const KUrl &dirUrl)
: d(new KFileItemPrivate(entry, dirUrl, true))
{
}
KFileItem::KFileItem(mode_t mode, mode_t permissions, const KUrl &url)
: d(new KFileItemPrivate(KIO::UDSEntry(), mode, permissions, url, false))
KFileItem::KFileItem(const KUrl &url)
: d(new KFileItemPrivate(KIO::UDSEntry(), url, false))
{
}
KFileItem::KFileItem( const KUrl &url, const QString &mimeType, mode_t mode)
: d(new KFileItemPrivate(KIO::UDSEntry(), mode, KFileItem::Unknown, url, false))
{
if (!mimeType.isEmpty()) {
d->m_pMimeType = KMimeType::mimeType(mimeType);
}
}
KFileItem::KFileItem(const KFileItem &other)
: d(other.d)

View file

@ -70,34 +70,18 @@ public:
* This is the preferred constructor when using KIO::listDir().
*
* @param entry the KIO entry used to get the file, contains info about it
* @param itemOrDirUrl the URL of the item or of the directory containing this item (see urlIsDirectory).
* @param urlIsDirectory specifies if the url is just the directory of the
* fileitem and the filename from the UDSEntry should be used.
* @param dirUrl the URL of the directory containing this item.
*
* When creating KFileItems out of the UDSEntry emitted by a KIO list job,
* use KFileItem(entry, listjob->url(), true);
* use KFileItem(entry, listjob->url());
*/
KFileItem(const KIO::UDSEntry &entry, const KUrl &itemOrDirUrl);
KFileItem(const KIO::UDSEntry &entry, const KUrl &dirUrl);
/**
* Creates an item representing a file, from all the necessary info for it.
* @param mode the file mode (according to stat() (e.g. S_IFDIR...)
* Set to KFileItem::Unknown if unknown. For local files, KFileItem will use stat().
* @param permissions the access permissions
* If you set both the mode and the permissions, you save a ::stat() for
* local files.
* Set to KFileItem::Unknown if you don't know the mode or the permission.
* Creates an item representing a file.
* @param url the file url
*/
KFileItem(mode_t mode, mode_t permissions, const KUrl &url);
/**
* Creates an item representing a file, for which the mimetype is already known.
* @param url the file url
* @param mimeType the name of the file's mimetype
* @param mode the mode (S_IFDIR...)
*/
KFileItem(const KUrl &url, const QString &mimeType, mode_t mode);
KFileItem(const KUrl &url);
/**
* Copy constructor

View file

@ -174,7 +174,7 @@ RenameDialog::RenameDialog(QWidget *parent, const QString & _caption,
pLayout->addWidget(lb);
} else if (_mode & M_OVERWRITE) {
if (d->src.isLocalFile()) {
d->srcItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, d->src);
d->srcItem = KFileItem(d->src);
} else {
UDSEntry srcUds;
@ -187,7 +187,7 @@ RenameDialog::RenameDialog(QWidget *parent, const QString & _caption,
}
if (d->dest.isLocalFile()) {
d->destItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, d->dest);
d->destItem = KFileItem(d->dest);
} else {
UDSEntry destUds;