KIO

kfileitem.h
1 /* This file is part of the KDE project
2  Copyright (C) 1999-2006 David Faure <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KFILEITEM_H
21 #define KFILEITEM_H
22 
23 #include "kiocore_export.h"
24 #include <kio/global.h>
25 #include <kacl.h>
26 #include <kio/udsentry.h>
27 #include <QDateTime>
28 #include <QUrl>
29 #include <QFile>
30 
31 #include <QMimeType>
32 #include <QList>
33 #include <qplatformdefs.h>
34 
35 class KFileItemPrivate;
36 
47 class KIOCORE_EXPORT KFileItem
48 {
49 public:
50  enum { Unknown = static_cast<mode_t>(-1) };
51 
58  enum FileTimes {
59  // warning: don't change without looking at the Private class
60  ModificationTime = 0,
61  AccessTime = 1,
62  CreationTime = 2
63  //ChangeTime
64  };
65 
66  enum MimeTypeDetermination {
67  NormalMimeTypeDetermination = 0,
68  SkipMimeTypeFromContent
69  };
70 
74  KFileItem();
75 
91  KFileItem(const KIO::UDSEntry &entry, const QUrl &itemOrDirUrl,
92  bool delayedMimeTypes = false,
93  bool urlIsDirectory = false);
94 
95 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
96 
111  KIOCORE_DEPRECATED_VERSION(5, 0, "See API docs")
112  KFileItem(mode_t mode, mode_t permissions, const QUrl &url,
113  bool delayedMimeTypes = false);
114 #endif
115 
122  KFileItem(const QUrl &url, const QString &mimeType = QString(), mode_t mode = KFileItem::Unknown); // KF6 TODO: explicit!
123 
136  KFileItem(const QUrl &url, KFileItem::MimeTypeDetermination mimeTypeDetermination);
137 
141  KFileItem(const KFileItem&);
142 
146  ~KFileItem();
147 
152  KFileItem(KFileItem&&);
153 
157  KFileItem& operator=(const KFileItem&);
158 
163  KFileItem& operator=(KFileItem&&);
164 
169  void refresh();
170 
175  void refreshMimeType();
176 
182  void setDelayedMimeTypes(bool b);
183 
188  QUrl url() const;
189 
195  void setUrl(const QUrl &url);
196 
204  void setLocalPath(const QString &path);
205 
212  void setName(const QString &name);
213 
218  mode_t permissions() const;
219 
224  QString permissionsString() const;
225 
230  bool hasExtendedACL() const;
231 
236  KACL ACL() const;
237 
242  KACL defaultACL() const;
243 
248  mode_t mode() const;
249 
254  QString user() const;
255 
260  QString group() const;
261 
267  bool isLink() const;
268 
273  bool isDir() const;
274 
279  bool isFile() const;
280 
287  bool isReadable() const;
288 
295  bool isWritable() const;
296 
301  bool isHidden() const;
302 
308  bool isSlow() const;
309 
316  bool isDesktopFile() const;
317 
322  QString linkDest() const;
323 
330  QUrl targetUrl() const;
331 
337  QString localPath() const;
338 
343  KIO::filesize_t size() const;
344 
354  KIO::filesize_t recursiveSize() const;
355 
362  QDateTime time(FileTimes which) const;
363 
371  QString timeString(FileTimes which = ModificationTime) const;
372 
373 #if KIOCORE_ENABLE_DEPRECATED_SINCE(4, 0)
374  KIOCORE_DEPRECATED_VERSION(4, 0, "Use KFileItem::timeString(FileTimes)")
375  QString timeString(unsigned int which) const;
376 #endif
377 
382  bool isLocalFile() const;
383 
389  QString text() const;
390 
398  QString name(bool lowerCase = false) const;
399 
406  QString mimetype() const;
407 
414  QMimeType determineMimeType() const;
415 
421  QMimeType currentMimeType() const;
422 
427  bool isFinalIconKnown() const;
428 
435  bool isMimeTypeKnown() const;
436 
442  QString mimeComment() const;
443 
449  QString iconName() const;
450 
457  QStringList overlays() const;
458 
465  QString comment() const;
466 
472  QString getStatusBarInfo() const;
473 
474 #if KIOCORE_ENABLE_DEPRECATED_SINCE(4, 0)
475 
485  KIOCORE_DEPRECATED_VERSION(4, 0, "See API docs")
486  bool acceptsDrops() const;
487 #endif
488 
494  KIO::UDSEntry entry() const;
495 
501  bool isRegularFile() const;
502 
511  bool cmp(const KFileItem &item) const;
512 
516  bool operator==(const KFileItem &other) const;
517 
521  bool operator!=(const KFileItem &other) const;
522 
527  bool operator<(const KFileItem &other) const;
528 
533  bool operator<(const QUrl &other) const;
534 
539  operator QVariant() const;
540 
541 #if KIOCORE_ENABLE_DEPRECATED_SINCE(4, 0)
542 
545  KIOCORE_DEPRECATED_VERSION(4, 0, "Use KFileItem::operator=(const KFileItem&)")
546  void assign(const KFileItem &item);
547 #endif
548 
554  QUrl mostLocalUrl(bool *local = nullptr) const;
555 
556 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 0)
557 
560  KIOCORE_DEPRECATED_VERSION(5, 0, "Use KFileItem::mostLocalUrl(bool *)")
561  QUrl mostLocalUrl(bool &local) const { return mostLocalUrl(&local); }
562 #endif
563 
567  bool isNull() const;
568 
569 private:
571 
575  void setHidden();
576 
577 private:
578  KIOCORE_EXPORT friend QDataStream &operator<< (QDataStream &s, const KFileItem &a);
579  KIOCORE_EXPORT friend QDataStream &operator>> (QDataStream &s, KFileItem &a);
580 
581  friend class KFileItemTest;
582  friend class KCoreDirListerCache;
583 };
584 
585 Q_DECLARE_METATYPE(KFileItem)
586 Q_DECLARE_TYPEINFO(KFileItem, Q_MOVABLE_TYPE);
587 
588 inline uint qHash(const KFileItem &item)
589 {
590  return qHash(item.url());
591 }
592 
599 class KIOCORE_EXPORT KFileItemList : public QList<KFileItem>
600 {
601 public:
603  KFileItemList();
604 
606  KFileItemList(const QList<KFileItem> &items);
607 
613  KFileItem findByName(const QString &fileName) const;
614 
620  KFileItem findByUrl(const QUrl &url) const;
621 
623  QList<QUrl> urlList() const;
624 
627  QList<QUrl> targetUrlList() const;
628 
629  // TODO KDE-5 add d pointer here so that we can merge KFileItemListProperties into KFileItemList
630 };
631 
632 KIOCORE_EXPORT QDataStream &operator<< (QDataStream &s, const KFileItem &a);
633 KIOCORE_EXPORT QDataStream &operator>> (QDataStream &s, KFileItem &a);
634 
639 KIOCORE_EXPORT QDebug operator<<(QDebug stream, const KFileItem &item);
640 
641 #endif
qulonglong filesize_t
64-bit file size
Definition: global.h:51
FileTimes
The timestamps associated with a file.
Definition: kfileitem.h:58
Universal Directory Service.
Definition: udsentry.h:88
QDataStream & operator>>(QDataStream &in, QList< T > &list)
List of KFileItems, which adds a few helper methods to QList<KFileItem>.
Definition: kfileitem.h:599
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
QUrl mostLocalUrl(bool &local) const
Definition: kfileitem.h:561
QList< T > & operator<<(const T &value)
The KACL class encapsulates a POSIX Access Control List.
Definition: kacl.h:47
QUrl url() const
Returns the url of the file.
Definition: kfileitem.cpp:1494
A KFileItem is a generic class to handle a file, local or remote.
Definition: kfileitem.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 11 2020 23:00:26 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.