NepomukDaemons
folderselectionmodel.h
Go to the documentation of this file.00001 /* This file is part of the KDE Project 00002 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org> 00003 00004 Based on CollectionSetup.h from the Amarok project 00005 (C) 2003 Scott Wheeler <wheeler@kde.org> 00006 (C) 2004 Max Howell <max.howell@methylblue.com> 00007 (C) 2004 Mark Kretschmann <markey@web.de> 00008 (C) 2008 Seb Ruiz <ruiz@kde.org> 00009 (C) 2008 Sebastian Trueg <trueg@kde.org> 00010 00011 This library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Library General Public 00013 License version 2 as published by the Free Software Foundation. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Library General Public License for more details. 00019 00020 You should have received a copy of the GNU Library General Public License 00021 along with this library; see the file COPYING.LIB. If not, write to 00022 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00023 Boston, MA 02110-1301, USA. 00024 */ 00025 00026 #ifndef _FOLDER_SELECTION_MODEL_H_ 00027 #define _FOLDER_SELECTION_MODEL_H_ 00028 00029 #include <QtGui/QFileSystemModel> 00030 #include <QtCore/QSet> 00031 00032 00033 class FolderSelectionModel : public QFileSystemModel 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 FolderSelectionModel( QObject* parent = 0 ); 00039 virtual ~FolderSelectionModel(); 00040 00041 enum IncludeState { 00042 StateNone, 00043 StateInclude, 00044 StateExclude, 00045 StateIncludeInherited, 00046 StateExcludeInherited 00047 }; 00048 00049 enum CustomRoles { 00050 IncludeStateRole = 7777 00051 }; 00052 00053 Qt::ItemFlags flags( const QModelIndex &index ) const; 00054 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; 00055 bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ); 00056 00057 void setFolders( const QStringList& includeDirs, const QStringList& exclude ); 00058 QStringList includeFolders() const; 00059 QStringList excludeFolders() const; 00060 00064 void includePath( const QString& ); 00065 00069 void excludePath( const QString& ); 00070 00071 int columnCount( const QModelIndex& ) const { return 1; } 00072 00073 IncludeState includeState( const QModelIndex& ) const; 00074 IncludeState includeState( const QString& path ) const; 00075 00076 private: 00077 bool isForbiddenPath( const QString& path ) const; 00078 00079 QSet<QString> m_included; 00080 QSet<QString> m_excluded; 00081 }; 00082 00083 #endif