KIO
kdirmodel.cpp
47 u.setPath(QDir::cleanPath(u.path())); // remove double slashes in the path, simplify "foo/." to "foo/", etc.
48 u = u.adjusted(QUrl::StripTrailingSlash); // KDirLister does this too, so we remove the slash before comparing with the root node url.
49 if (u.scheme().startsWith(QStringLiteral("ksvn")) || u.scheme().startsWith(QStringLiteral("svn"))) {
141 // If we listed the directory, the child count is known. Otherwise it can be set via setChildCount.
275 if (url.scheme().startsWith(QStringLiteral("ksvn")) || url.scheme().startsWith(QStringLiteral("svn"))) {
297 // key = current known parent node (always a KDirModelDirNode but KDirModelNode is more convenient),
301 QStringList m_allCurrentDestUrls; // list of all dest urls that have jobs on them (e.g. copy, download)
304KDirModelNode *KDirModelPrivate::nodeForUrl(const QUrl &_url) const // O(1), well, O(length of url as a string)
332 dirNode = static_cast<KDirModelDirNode *>(m_rootNode->m_childNodes.at(0)); // ### will be incorrect if we list drives on Windows
359 qCWarning(category) << "The KIO worker for" << url.scheme() << "violates the hierarchy structure:"
394 qCDebug(category) << "Dumping contents of KDirModel" << q << "dirLister url:" << m_dirLister->url();
423 * The internal pointer of the QModelIndex for a given file is the node for that file in our own tree.
424 * E.g. index(2,0) returns a QModelIndex with row=2 internalPointer=<KDirModelNode for the 3rd child of the root>
462 connect(d->m_dirLister, &KCoreDirLister::itemsAdded, this, [this](const QUrl &dirUrl, const KFileItemList &items) {
465 connect(d->m_dirLister, &KCoreDirLister::listingDirCompleted, this, [this](const QUrl &dirUrl) {
468 connect(d->m_dirLister, &KCoreDirLister::itemsDeleted, this, [this](const KFileItemList &items) {
471 connect(d->m_dirLister, &KCoreDirLister::refreshItems, this, [this](const QList<QPair<KFileItem, KFileItem>> &items) {
477 connect(d->m_dirLister, &KCoreDirLister::redirection, this, [this](const QUrl &oldUrl, const QUrl &newUrl) {
498 visibleRootItem.setName(url.path() == QLatin1String("/") ? QStringLiteral("/") : url.fileName());
529 qCWarning(category) << "Items emitted in directory" << directoryUrl << "but that directory isn't in KDirModel!"
547 qCDebug(category) << items.count() << "in" << directoryUrl << "index=" << debugIndex(index) << "newRowCount=" << newRowCount;
553 qCDebug(category) << "urlsBeingFetched for dir" << dirNode << directoryUrl << ":" << urlsBeingFetched;
561 KDirModelNode *node = isDir ? new KDirModelDirNode(dirNode, item) : new KDirModelNode(dirNode, item);
580 // qDebug() << "Listing found" << dirUrl.url() << "which is a parent of fetched url" << urlFetched;
711 KDirModelNode *node = nodeForUrl(oldUrl); // O(n); maybe we could look up to the parent only once
712 // qDebug() << "in model for" << m_dirLister->url() << ":" << oldUrl << "->" << newUrl << "node=" << node;
716 if (node != m_rootNode) { // we never set an item in the rootnode, we use m_dirLister->rootItem instead.
725 node = newItem.isDir() ? new KDirModelDirNode(dirNode, newItem) : new KDirModelNode(dirNode, newItem);
906 || (!(iconName.endsWith(QLatin1String(".svg")) || iconName.endsWith(QLatin1String(".svgz"))) && icon.availableSizes().isEmpty())) {
950 && !(findData.cFileName[0] == '.' && findData.cFileName[1] == '.' && findData.cFileName[2] == '\0')) {
1008 if (newName.isEmpty() || newName == item.text() || (newName == QLatin1Char('.')) || (newName == QLatin1String(".."))) {
1013 KIO::Job *job = KIO::rename(item.url(), newUrl, item.url().isLocalFile() ? KIO::HideProgressInfo : KIO::DefaultFlags);
1016 KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, QList<QUrl>() << item.url(), newUrl, job);
1110 connect(&JobUrlCache::instance(), &JobUrlCache::jobUrlsChanged, this, [this](const QStringList &urlList) {
1345 // But this wastes memory, and how often does someone open and re-open an empty dir in a treeview?
1376bool KDirModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
void listingDirCompleted(const QUrl &dirUrl)
Tell the view that the listing of the directory dirUrl is finished.
void clear()
Signals to the view to remove all items (when e.g. going from dirA to dirB).
QUrl url() const
Returns the top level URL that is listed by this KCoreDirLister.
Definition kcoredirlister.cpp:2216
void refreshItems(const QList< QPair< KFileItem, KFileItem > > &items)
Signal an item to refresh (its MIME-type/icon/name has changed).
void redirection(const QUrl &oldUrl, const QUrl &newUrl)
Signals a redirection.
void itemsDeleted(const KFileItemList &items)
Signal that items have been deleted.
@ Reload
Indicates whether to use the cache or to reread the directory from the disk.
Definition kcoredirlister.h:80
void itemsAdded(const QUrl &directoryUrl, const KFileItemList &items)
Signal that new items were found during directory listing.
Subclass of KCoreDirLister which uses QWidgets to show error messages and to associate jobs with wind...
Definition kdirlister.h:25
QHash< int, QByteArray > roleNames() const override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:1444
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:999
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Reimplemented from QAbstractItemModel. Returns ColumnCount.
Definition kdirmodel.cpp:852
Q_INVOKABLE void itemChanged(const QModelIndex &index)
Notify the model that the item at this index has changed.
Definition kdirmodel.cpp:838
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:857
@ DropOnLocalExecutable
allow drops on local executables, shell scripts and desktop files. Can be used with DropOnDirectory.
Definition kdirmodel.h:172
QModelIndex sibling(int row, int column, const QModelIndex &index) const override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:1080
Q_INVOKABLE QModelIndex indexForItem(const KFileItem &) const
Return the index for a given kfileitem.
Definition kdirmodel.cpp:1201
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Reimplemented from QAbstractItemModel. O(1)
Definition kdirmodel.cpp:1217
Q_INVOKABLE void clearAllPreviews()
Forget all previews (optimization for turning previews off).
Definition kdirmodel.cpp:833
Q_INVOKABLE void openUrl(const QUrl &url, OpenUrlFlags flags=NoFlags)
Display the contents of url in the model.
Definition kdirmodel.cpp:482
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Reimplemented from QAbstractItemModel. Not implemented yet.
Definition kdirmodel.cpp:1376
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Reimplemented from QAbstractItemModel. Returns the column titles.
Definition kdirmodel.cpp:1230
@ FileItemRole
returns the KFileItem for a given index. roleName is "fileItem".
Definition kdirmodel.h:160
@ ChildCountRole
returns the number of items in a directory, or ChildCountUnknown. roleName is "childCount".
Definition kdirmodel.h:161
@ HasJobRole
returns whether or not there is a job on an item (file/directory). roleName is "hasJob".
Definition kdirmodel.h:162
void fetchMore(const QModelIndex &parent) override
Reimplemented from QAbstractItemModel. Lists the subdirectory.
Definition kdirmodel.cpp:1353
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Reimplemented from QAbstractItemModel. Not implemented.
Definition kdirmodel.cpp:993
QMimeData * mimeData(const QModelIndexList &indexes) const override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:1159
void needSequenceIcon(const QModelIndex &index, int sequenceIndex)
Emitted when another icon sequence index is requested.
KDirLister * dirLister() const
Return the directory lister used by this model.
Definition kdirmodel.cpp:516
void setJobTransfersVisible(bool show)
Enable/Disable the displaying of an animated overlay that is shown for any destination urls (in the v...
Definition kdirmodel.cpp:1102
bool canFetchMore(const QModelIndex &parent) const override
Reimplemented from QAbstractItemModel. Returns true for empty directories.
Definition kdirmodel.cpp:1337
bool jobTransfersVisible() const
Returns whether or not displaying job transfers has been enabled.
Definition kdirmodel.cpp:1120
void setDirLister(KDirLister *dirLister)
Set the directory lister to use by this model, instead of the default KDirLister created internally.
Definition kdirmodel.cpp:454
Q_INVOKABLE void setDropsAllowed(DropsAllowed dropsAllowed)
Set whether dropping onto items should be allowed, and for which kind of item Drops are disabled by d...
Definition kdirmodel.cpp:1388
@ Reload
Indicates whether to use the cache or to reread the directory from the disk.
Definition kdirmodel.h:59
KFileItem itemForIndex(const QModelIndex &index) const
Return the fileitem for a given index.
Definition kdirmodel.cpp:1189
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:1043
Q_INVOKABLE void expandToUrl(const QUrl &url)
Lists subdirectories using fetchMore() as needed until the given url exists in the model.
Definition kdirmodel.cpp:1393
QStringList mimeTypes() const override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:1154
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
Reimplemented from QAbstractItemModel. Returns true for directories.
Definition kdirmodel.cpp:1256
static QList< QUrl > simplifiedUrlList(const QList< QUrl > &urls)
Remove urls from the list if an ancestor is present on the list.
Definition kdirmodel.cpp:1125
Q_INVOKABLE QModelIndex indexForUrl(const QUrl &url) const
Return the index for a given url.
Definition kdirmodel.cpp:1207
void requestSequenceIcon(const QModelIndex &index, int sequenceIndex)
This emits the needSequenceIcon signal, requesting another sequence icon.
Definition kdirmodel.cpp:1097
Qt::ItemFlags flags(const QModelIndex &index) const override
Reimplemented from QAbstractItemModel.
Definition kdirmodel.cpp:1291
List of KFileItems, which adds a few helper methods to QList<KFileItem>.
Definition kfileitem.h:632
Q_INVOKABLE QDateTime time(KFileItem::FileTimes which) const
Requests the modification, access or creation time, depending on which.
Definition kfileitem.cpp:871
MostLocalUrlResult isMostLocalUrl() const
Returns a MostLocalUrlResult, with the local Url for this item if possible (otherwise an empty Url),...
Definition kfileitem.cpp:1600
QString permissionsString() const
Returns the access permissions for the file as a string.
Definition kfileitem.cpp:1562
void setName(const QString &name)
Sets the item's name (i.e. the filename).
Definition kfileitem.cpp:713
void recordJob(CommandType op, const QList< QUrl > &src, const QUrl &dst, KIO::Job *job)
Record this job while it's happening and add a command for it so that the user can undo it.
Definition fileundomanager.cpp:265
The base class for all jobs.
QString errorString() const override
Converts an error code and a non-i18n error message into an error message in the current language.
Definition job_error.cpp:26
A KIO job that retrieves information about a file or directory.
Universal Directory Service.
void setAutoErrorHandlingEnabled(bool enable)
int error() const
void result(KJob *job)
KJobUiDelegate * uiDelegate() const
Q_SCRIPTABLE Q_NOREPLY void start()
QString i18nc(const char *context, const char *text, const TYPE &arg...)
KIOCORE_EXPORT SimpleJob * rename(const QUrl &src, const QUrl &dest, JobFlags flags=DefaultFlags)
Rename a file or directory.
Definition simplejob.cpp:349
KIOCORE_EXPORT StatJob * stat(const QUrl &url, JobFlags flags=DefaultFlags)
Find all details for one file or directory.
Definition statjob.cpp:203
KIOCORE_EXPORT QString convertSize(KIO::filesize_t size)
Converts size from bytes to the string representation.
Definition global.cpp:43
KIOCORE_EXPORT QString encodeFileName(const QString &str)
Encodes (from the text displayed to the real filename) This translates '/' into a "unicode fraction s...
Definition global.cpp:111
QIcon addOverlays(const QIcon &icon, const QHash< Qt::Corner, QIcon > &overlays)
const QList< QKeySequence > & end()
KCOREADDONS_EXPORT void setUrls(const QList< QUrl > &urls, const QList< QUrl > &mostLocalUrls, QMimeData *mimeData)
KCOREADDONS_EXPORT QStringList mimeDataTypes()
void beginInsertRows(const QModelIndex &parent, int first, int last)
void beginRemoveRows(const QModelIndex &parent, int first, int last)
QModelIndex createIndex(int row, int column, const void *ptr) const const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void endRemoveRows()
virtual QHash< int, QByteArray > roleNames() const const
virtual void sort(int column, Qt::SortOrder order)
Filters
QString cleanPath(const QString &path)
bool isAbsolutePath(const QString &path)
Subdirectories
bool hasNext() const const
QByteArray encodeName(const QString &fileName)
bool isExecutable() const const
void clear()
iterator insert(const Key &key, const T &value)
bool remove(const Key &key)
void addPixmap(const QPixmap &pixmap, Mode mode, State state)
QList< QSize > availableSizes(Mode mode, State state) const const
QIcon fromTheme(const QString &name)
bool isNull() const const
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
iterator begin()
const_iterator constBegin() const const
const_iterator constEnd() const const
qsizetype count() const const
iterator end()
iterator erase(const_iterator begin, const_iterator end)
qsizetype indexOf(const AT &value, qsizetype from) const const
iterator insert(const_iterator before, parameter_type value)
bool isEmpty() const const
void reserve(qsizetype size)
qsizetype size() const const
T takeAt(qsizetype i)
ShortFormat
QString toString(QDate date, FormatType format) const const
size_type remove(const Key &key)
T value(const Key &key, const T &defaultValue) const const
QString
bool inherits(const QString &mimeTypeName) const const
int column() const const
void * internalPointer() const const
bool isValid() const const
int row() const const
QModelIndex sibling(int row, int column) const const
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
QString left(qsizetype n) const const
qsizetype length() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
const ushort * utf16() const const
typedef Alignment
typedef DropActions
DisplayRole
typedef ItemFlags
Orientation
SortOrder
StripTrailingSlash
QUrl adjusted(FormattingOptions options) const const
QString fileName(ComponentFormattingOptions options) const const
bool hasFragment() const const
bool hasQuery() const const
bool isLocalFile() const const
bool isParentOf(const QUrl &childUrl) const const
bool isValid() const const
QString path(ComponentFormattingOptions options) const const
QString scheme() const const
void setFragment(const QString &fragment, ParsingMode mode)
void setPath(const QString &path, ParsingMode mode)
void setQuery(const QString &query, ParsingMode mode)
QString toString(FormattingOptions options) const const
QString url(FormattingOptions options) const const
QVariant fromValue(T &&value)
QString toString() const const
int typeId() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.