KIO
kdirmodel.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2006 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 #ifndef KDIRMODEL_H 00020 #define KDIRMODEL_H 00021 00022 #include <QtCore/QAbstractItemModel> 00023 #include <kio/kio_export.h> 00024 #include <kfileitem.h> 00025 00026 class KDirLister; 00027 class KDirModelPrivate; 00028 class JobUrlCache; 00029 00048 class KIO_EXPORT KDirModel : public QAbstractItemModel 00049 { 00050 Q_OBJECT 00051 00052 public: 00056 explicit KDirModel( QObject* parent = 0 ); 00057 ~KDirModel(); 00058 00063 void setDirLister( KDirLister* dirLister ); 00064 00068 KDirLister* dirLister() const; 00069 00073 KFileItem itemForIndex( const QModelIndex& index ) const; 00074 00079 #ifndef KDE_NO_DEPRECATED 00080 KDE_DEPRECATED QModelIndex indexForItem( const KFileItem* ) const; 00081 #endif 00082 00086 QModelIndex indexForItem( const KFileItem& ) const; 00087 00091 QModelIndex indexForUrl(const KUrl& url) const; 00092 00106 void expandToUrl(const KUrl& url); 00107 00114 void itemChanged( const QModelIndex& index ); 00115 00116 /*** 00117 * Useful "default" columns. Views can use a proxy to have more control over this. 00118 */ 00119 enum ModelColumns { 00120 Name = 0, 00121 Size, 00122 ModifiedTime, 00123 Permissions, 00124 Owner, 00125 Group, 00126 Type, 00127 ColumnCount 00128 }; 00129 00132 enum { ChildCountUnknown = -1 }; 00133 00134 enum AdditionalRoles { 00135 // Note: use printf "0x%08X\n" $(($RANDOM*$RANDOM)) 00136 // to define additional roles. 00137 FileItemRole = 0x07A263FF, 00138 ChildCountRole = 0x2C4D0A40, 00139 HasJobRole = 0x01E555A5 00140 }; 00141 00142 enum DropsAllowedFlag { 00143 NoDrops = 0, 00144 DropOnDirectory = 1, 00145 DropOnAnyFile = 2, 00146 DropOnLocalExecutable = 4 00147 }; 00148 Q_DECLARE_FLAGS(DropsAllowed, DropsAllowedFlag) 00149 00150 00151 00152 void setDropsAllowed(DropsAllowed dropsAllowed); 00153 00155 virtual bool canFetchMore ( const QModelIndex & parent ) const; 00157 virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const; 00159 virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; 00161 virtual bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ); 00163 virtual void fetchMore ( const QModelIndex & parent ); 00165 virtual Qt::ItemFlags flags ( const QModelIndex & index ) const; 00167 virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const; 00169 virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; 00171 virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; 00173 virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const; 00175 virtual QStringList mimeTypes () const; 00177 virtual QModelIndex parent ( const QModelIndex & index ) const; 00179 virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const; 00182 virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); 00184 virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder ); 00185 00186 00197 static KUrl::List simplifiedUrlList( const KUrl::List & urls ); 00198 00210 void requestSequenceIcon(const QModelIndex& index, int sequenceIndex); 00211 00228 void setJobTransfersVisible(bool value); 00229 00234 bool jobTransfersVisible() const; 00235 00236 Q_SIGNALS: 00243 void expand(const QModelIndex& index); 00253 void needSequenceIcon(const QModelIndex& index, int sequenceIndex); 00254 00255 private: 00256 // Make those private, they shouldn't be called by applications 00257 virtual bool insertRows(int , int, const QModelIndex & = QModelIndex()); 00258 virtual bool insertColumns(int, int, const QModelIndex & = QModelIndex()); 00259 virtual bool removeRows(int, int, const QModelIndex & = QModelIndex()); 00260 virtual bool removeColumns(int, int, const QModelIndex & = QModelIndex()); 00261 00262 private: 00263 friend class KDirModelPrivate; 00264 KDirModelPrivate *const d; 00265 00266 Q_PRIVATE_SLOT( d, void _k_slotNewItems(const KUrl&, const KFileItemList&) ) 00267 Q_PRIVATE_SLOT( d, void _k_slotDeleteItems(const KFileItemList&) ) 00268 Q_PRIVATE_SLOT( d, void _k_slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&) ) 00269 Q_PRIVATE_SLOT( d, void _k_slotClear() ) 00270 Q_PRIVATE_SLOT( d, void _k_slotRedirection(const KUrl&, const KUrl&) ) 00271 Q_PRIVATE_SLOT( d, void _k_slotJobUrlsChanged(const QStringList&)) 00272 }; 00273 00274 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirModel::DropsAllowed) 00275 00276 #endif /* KDIRMODEL_H */
KDE 4.6 API Reference