• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

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 
00040 class KIO_EXPORT KDirModel : public QAbstractItemModel
00041 {
00042     Q_OBJECT
00043 
00044 public:
00048     explicit KDirModel( QObject* parent = 0 );
00049     ~KDirModel();
00050 
00055     void setDirLister( KDirLister* dirLister );
00056 
00060     KDirLister* dirLister() const;
00061 
00065     KFileItem itemForIndex( const QModelIndex& index ) const;
00066 
00071     KDE_DEPRECATED QModelIndex indexForItem( const KFileItem* ) const;
00072 
00076     QModelIndex indexForItem( const KFileItem& ) const;
00077 
00081     QModelIndex indexForUrl(const KUrl& url) const;
00082 
00096     void expandToUrl(const KUrl& url);
00097 
00104     void itemChanged( const QModelIndex& index );
00105 
00106     /***
00107      * Useful "default" columns. Views can use a proxy to have more control over this.
00108      */
00109     enum ModelColumns {
00110         Name = 0,
00111         Size,
00112         ModifiedTime,
00113         Permissions,
00114         Owner,
00115         Group,
00116         Type,
00117         ColumnCount
00118     };
00119 
00122     enum { ChildCountUnknown = -1 };
00123 
00124     enum AdditionalRoles {
00125         // Note: use   printf "0x%08X\n" $(($RANDOM*$RANDOM))
00126         // to define additional roles.
00127         FileItemRole = 0x07A263FF,  
00128         ChildCountRole = 0x2C4D0A40 
00129     };
00130 
00131     enum DropsAllowedFlag {
00132         NoDrops = 0,
00133         DropOnDirectory = 1, 
00134         DropOnAnyFile = 2, 
00135         DropOnLocalExecutable = 4 
00136     };
00137     Q_DECLARE_FLAGS(DropsAllowed, DropsAllowedFlag)
00138 
00139     
00140 
00141     void setDropsAllowed(DropsAllowed dropsAllowed);
00142 
00144     virtual bool canFetchMore ( const QModelIndex & parent ) const;
00146     virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
00148     virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
00150     virtual bool dropMimeData ( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
00152     virtual void fetchMore ( const QModelIndex & parent );
00154     virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
00156     virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
00158     virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00160     virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
00162     virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
00164     virtual QStringList mimeTypes () const;
00166     virtual QModelIndex parent ( const QModelIndex & index ) const;
00168     virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
00171     virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
00173     virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder );
00174 
00175 
00186     static KUrl::List simplifiedUrlList( const KUrl::List & urls );
00187 
00188 Q_SIGNALS:
00195     void expand(const QModelIndex& index);
00196 
00197 private:
00198     // Make those private, they shouldn't be called by applications
00199     virtual bool insertRows(int , int, const QModelIndex & = QModelIndex());
00200     virtual bool insertColumns(int, int, const QModelIndex & = QModelIndex());
00201     virtual bool removeRows(int, int, const QModelIndex & = QModelIndex());
00202     virtual bool removeColumns(int, int, const QModelIndex & = QModelIndex());
00203 
00204 private:
00205     friend class KDirModelPrivate;
00206     KDirModelPrivate *const d;
00207 
00208     Q_PRIVATE_SLOT( d, void _k_slotNewItems(const KUrl&, const KFileItemList&) )
00209     Q_PRIVATE_SLOT( d, void _k_slotDeleteItems(const KFileItemList&) )
00210     Q_PRIVATE_SLOT( d, void _k_slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&) )
00211     Q_PRIVATE_SLOT( d, void _k_slotClear() )
00212     Q_PRIVATE_SLOT( d, void _k_slotRedirection(const KUrl&, const KUrl&) )
00213 };
00214 
00215 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirModel::DropsAllowed)
00216 
00217 #endif /* KDIRMODEL_H */

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal