KIO

kfileitem.h
1 /*
2  This file is part of the KDE project
3  SPDX-FileCopyrightText: 1999-2006 David Faure <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KFILEITEM_H
9 #define KFILEITEM_H
10 
11 #include "kiocore_export.h"
12 #include <kio/global.h>
13 #include <kacl.h>
14 #include <kio/udsentry.h>
15 #include <QDateTime>
16 #include <QUrl>
17 #include <QFile>
18 
19 #include <QMimeType>
20 #include <QList>
21 #include <qplatformdefs.h>
22 
23 class KFileItemPrivate;
24 
35 class KIOCORE_EXPORT KFileItem
36 {
37 public:
38  enum { Unknown = static_cast<mode_t>(-1) };
39 
46  enum FileTimes {
47  // warning: don't change without looking at the Private class
48  ModificationTime = 0,
49  AccessTime = 1,
50  CreationTime = 2
51  //ChangeTime
52  };
53 
54  enum MimeTypeDetermination {
55  NormalMimeTypeDetermination = 0,
56  SkipMimeTypeFromContent
57  };
58 
62  KFileItem();
63 
79  KFileItem(const KIO::UDSEntry &entry, const QUrl &itemOrDirUrl,
80  bool delayedMimeTypes = false,
81  bool urlIsDirectory = false);
82 
83 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
84 
99  KIOCORE_DEPRECATED_VERSION(5, 0, "See API docs")
100  KFileItem(mode_t mode, mode_t permissions, const QUrl &url,
101  bool delayedMimeTypes = false);
102 #endif
103 
110  KFileItem(const QUrl &url, const QString &mimeType = QString(), mode_t mode = KFileItem::Unknown); // KF6 TODO: explicit!
111 
124  KFileItem(const QUrl &url, KFileItem::MimeTypeDetermination mimeTypeDetermination);
125 
129  KFileItem(const KFileItem&);
130 
134  ~KFileItem();
135 
140  KFileItem(KFileItem&&);
141 
145  KFileItem& operator=(const KFileItem&);
146 
151  KFileItem& operator=(KFileItem&&);
152 
157  void refresh();
158 
163  void refreshMimeType();
164 
170  void setDelayedMimeTypes(bool b);
171 
176  QUrl url() const;
177 
183  void setUrl(const QUrl &url);
184 
192  void setLocalPath(const QString &path);
193 
200  void setName(const QString &name);
201 
206  mode_t permissions() const;
207 
212  QString permissionsString() const;
213 
218  bool hasExtendedACL() const;
219 
224  KACL ACL() const;
225 
230  KACL defaultACL() const;
231 
236  mode_t mode() const;
237 
242  QString user() const;
243 
248  QString group() const;
249 
255  bool isLink() const;
256 
261  bool isDir() const;
262 
267  bool isFile() const;
268 
275  bool isReadable() const;
276 
283  bool isWritable() const;
284 
289  bool isHidden() const;
290 
296  bool isSlow() const;
297 
304  bool isDesktopFile() const;
305 
310  QString linkDest() const;
311 
318  QUrl targetUrl() const;
319 
325  QString localPath() const;
326 
331  KIO::filesize_t size() const;
332 
342  KIO::filesize_t recursiveSize() const;
343 
350  QDateTime time(FileTimes which) const;
351 
359  QString timeString(FileTimes which = ModificationTime) const;
360 
361 #if KIOCORE_ENABLE_DEPRECATED_SINCE(4, 0)
362  KIOCORE_DEPRECATED_VERSION(4, 0, "Use KFileItem::timeString(FileTimes)")
363  QString timeString(unsigned int which) const;
364 #endif
365 
370  bool isLocalFile() const;
371 
377  QString text() const;
378 
386  QString name(bool lowerCase = false) const;
387 
394  QString mimetype() const;
395 
402  QMimeType determineMimeType() const;
403 
409  QMimeType currentMimeType() const;
410 
415  bool isFinalIconKnown() const;
416 
423  bool isMimeTypeKnown() const;
424 
430  QString mimeComment() const;
431 
437  QString iconName() const;
438 
445  QStringList overlays() const;
446 
453  QString comment() const;
454 
460  QString getStatusBarInfo() const;
461 
462 #if KIOCORE_ENABLE_DEPRECATED_SINCE(4, 0)
463 
473  KIOCORE_DEPRECATED_VERSION(4, 0, "See API docs")
474  bool acceptsDrops() const;
475 #endif
476 
482  KIO::UDSEntry entry() const;
483 
489  bool isRegularFile() const;
490 
499  bool cmp(const KFileItem &item) const;
500 
504  bool operator==(const KFileItem &other) const;
505 
509  bool operator!=(const KFileItem &other) const;
510 
515  bool operator<(const KFileItem &other) const;
516 
521  bool operator<(const QUrl &other) const;
522 
527  operator QVariant() const;
528 
529 #if KIOCORE_ENABLE_DEPRECATED_SINCE(4, 0)
530 
533  KIOCORE_DEPRECATED_VERSION(4, 0, "Use KFileItem::operator=(const KFileItem&)")
534  void assign(const KFileItem &item);
535 #endif
536 
542  QUrl mostLocalUrl(bool *local = nullptr) const;
543 
544 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
545 
548  KIOCORE_DEPRECATED_VERSION(5, 0, "Use KFileItem::mostLocalUrl(bool *)")
549  QUrl mostLocalUrl(bool &local) const { return mostLocalUrl(&local); }
550 #endif
551 
555  bool isNull() const;
556 
557 private:
559 
563  void setHidden();
564 
565 private:
566  KIOCORE_EXPORT friend QDataStream &operator<< (QDataStream &s, const KFileItem &a);
567  KIOCORE_EXPORT friend QDataStream &operator>> (QDataStream &s, KFileItem &a);
568 
569  friend class KFileItemTest;
570  friend class KCoreDirListerCache;
571 };
572 
573 Q_DECLARE_METATYPE(KFileItem)
574 Q_DECLARE_TYPEINFO(KFileItem, Q_MOVABLE_TYPE);
575 
576 inline uint qHash(const KFileItem &item)
577 {
578  return qHash(item.url());
579 }
580 
587 class KIOCORE_EXPORT KFileItemList : public QList<KFileItem>
588 {
589 public:
591  KFileItemList();
592 
594  KFileItemList(const QList<KFileItem> &items);
595 
598  KFileItemList(std::initializer_list<KFileItem> items);
599 
605  KFileItem findByName(const QString &fileName) const;
606 
612  KFileItem findByUrl(const QUrl &url) const;
613 
615  QList<QUrl> urlList() const;
616 
619  QList<QUrl> targetUrlList() const;
620 
621  // TODO KDE-5 add d pointer here so that we can merge KFileItemListProperties into KFileItemList
622 };
623 
624 KIOCORE_EXPORT QDataStream &operator<< (QDataStream &s, const KFileItem &a);
625 KIOCORE_EXPORT QDataStream &operator>> (QDataStream &s, KFileItem &a);
626 
631 KIOCORE_EXPORT QDebug operator<<(QDebug stream, const KFileItem &item);
632 
633 #endif
qulonglong filesize_t
64-bit file size
Definition: global.h:40
FileTimes
The timestamps associated with a file.
Definition: kfileitem.h:46
Universal Directory Service.
Definition: udsentry.h:77
QDataStream & operator>>(QDataStream &in, QList< T > &list)
List of KFileItems, which adds a few helper methods to QList<KFileItem>.
Definition: kfileitem.h:587
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
QUrl mostLocalUrl(bool &local) const
Definition: kfileitem.h:549
QList< T > & operator<<(const T &value)
The KACL class encapsulates a POSIX Access Control List.
Definition: kacl.h:35
QUrl url() const
Returns the url of the file.
Definition: kfileitem.cpp:1481
A KFileItem is a generic class to handle a file, local or remote.
Definition: kfileitem.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Dec 3 2020 23:01:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.