• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kio
kdirmodel.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2006 David Faure <faure@kde.org>
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#ifndef KDIRMODEL_H
20#define KDIRMODEL_H
21
22#include <QtCore/QAbstractItemModel>
23#include <kio/kio_export.h>
24#include <kfileitem.h>
25
26class KDirLister;
27class KDirModelPrivate;
28class JobUrlCache;
29
48class KIO_EXPORT KDirModel : public QAbstractItemModel
49{
50 Q_OBJECT
51
52public:
56 explicit KDirModel( QObject* parent = 0 );
57 ~KDirModel();
58
63 void setDirLister( KDirLister* dirLister );
64
68 KDirLister* dirLister() const;
69
73 KFileItem itemForIndex( const QModelIndex& index ) const;
74
79#ifndef KDE_NO_DEPRECATED
80 KDE_DEPRECATED QModelIndex indexForItem( const KFileItem* ) const;
81#endif
82
86 QModelIndex indexForItem( const KFileItem& ) const;
87
91 QModelIndex indexForUrl(const KUrl& url) const;
92
106 void expandToUrl(const KUrl& url);
107
114 void itemChanged( const QModelIndex& index );
115
116 /***
117 * Useful "default" columns. Views can use a proxy to have more control over this.
118 */
119 enum ModelColumns {
120 Name = 0,
121 Size,
122 ModifiedTime,
123 Permissions,
124 Owner,
125 Group,
126 Type,
127 ColumnCount
128 };
129
132 enum { ChildCountUnknown = -1 };
133
134 enum AdditionalRoles {
135 // Note: use printf "0x%08X\n" $(($RANDOM*$RANDOM))
136 // to define additional roles.
137 FileItemRole = 0x07A263FF,
138 ChildCountRole = 0x2C4D0A40,
139 HasJobRole = 0x01E555A5
140 };
141
142 enum DropsAllowedFlag {
143 NoDrops = 0,
144 DropOnDirectory = 1,
145 DropOnAnyFile = 2,
146 DropOnLocalExecutable = 4
147 };
148 Q_DECLARE_FLAGS(DropsAllowed, DropsAllowedFlag)
149
150
152 void setDropsAllowed(DropsAllowed dropsAllowed);
153
155 virtual bool canFetchMore ( const QModelIndex & parent ) const;
157 virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
159 virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
161 virtual bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
163 virtual void fetchMore ( const QModelIndex & parent );
165 virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
167 virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
169 virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
171 virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
173 virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
175 virtual QStringList mimeTypes () const;
177 virtual QModelIndex parent ( const QModelIndex & index ) const;
179 virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
182 virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
184 virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder );
185
186
197 static KUrl::List simplifiedUrlList( const KUrl::List & urls );
198
210 void requestSequenceIcon(const QModelIndex& index, int sequenceIndex);
211
228 void setJobTransfersVisible(bool value);
229
234 bool jobTransfersVisible() const;
235
236Q_SIGNALS:
243 void expand(const QModelIndex& index);
253 void needSequenceIcon(const QModelIndex& index, int sequenceIndex);
254
255private:
256 // Make those private, they shouldn't be called by applications
257 virtual bool insertRows(int , int, const QModelIndex & = QModelIndex());
258 virtual bool insertColumns(int, int, const QModelIndex & = QModelIndex());
259 virtual bool removeRows(int, int, const QModelIndex & = QModelIndex());
260 virtual bool removeColumns(int, int, const QModelIndex & = QModelIndex());
261
262private:
263 friend class KDirModelPrivate;
264 KDirModelPrivate *const d;
265
266 Q_PRIVATE_SLOT( d, void _k_slotNewItems(const KUrl&, const KFileItemList&) )
267 Q_PRIVATE_SLOT( d, void _k_slotDeleteItems(const KFileItemList&) )
268 Q_PRIVATE_SLOT( d, void _k_slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&) )
269 Q_PRIVATE_SLOT( d, void _k_slotClear() )
270 Q_PRIVATE_SLOT( d, void _k_slotRedirection(const KUrl&, const KUrl&) )
271 Q_PRIVATE_SLOT( d, void _k_slotJobUrlsChanged(const QStringList&))
272};
273
274Q_DECLARE_OPERATORS_FOR_FLAGS(KDirModel::DropsAllowed)
275
276#endif /* KDIRMODEL_H */
JobUrlCache
Definition: joburlcache_p.h:27
KDirLister
Helper class for the kiojob used to list and update a directory.
Definition: kdirlister.h:58
KDirModel
A model for a KIO-based directory tree.
Definition: kdirmodel.h:49
KDirModel::expand
void expand(const QModelIndex &index)
Emitted for each subdirectory that is a parent of a url passed to expandToUrl This allows to asynchro...
KDirModel::DropsAllowedFlag
DropsAllowedFlag
Definition: kdirmodel.h:142
KDirModel::AdditionalRoles
AdditionalRoles
Definition: kdirmodel.h:134
KDirModel::needSequenceIcon
void needSequenceIcon(const QModelIndex &index, int sequenceIndex)
Emitted when another icon sequence index is requested.
KDirModel::ModelColumns
ModelColumns
Definition: kdirmodel.h:119
KDirModel::Type
@ Type
Definition: kdirmodel.h:126
KDirModel::Size
@ Size
Definition: kdirmodel.h:121
KDirModel::ModifiedTime
@ ModifiedTime
Definition: kdirmodel.h:122
KDirModel::Permissions
@ Permissions
Definition: kdirmodel.h:123
KDirModel::Owner
@ Owner
Definition: kdirmodel.h:124
KDirModel::Group
@ Group
Definition: kdirmodel.h:125
KFileItemList
List of KFileItems, which adds a few helper methods to QList<KFileItem>.
Definition: kfileitem.h:675
KFileItem
A KFileItem is a generic class to handle a file, local or remote.
Definition: kfileitem.h:46
KUrl::List
KUrl
QAbstractItemModel
QList
QObject
QPair
kfileitem.h
kio_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal