CFileListProviderComp.h
Go to the documentation of this file.
1 #ifndef ifile_CFileListProviderComp_included
2 #define ifile_CFileListProviderComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QFileSystemWatcher>
7 #include <QtCore/QDir>
8 
9 // ACF includes
10 #include <imod/IModel.h>
12 #include <ilog/TLoggerCompWrap.h>
14 #include <ifile/IFileNameParam.h>
15 #include <ifile/IFileTypeInfo.h>
16 
17 
18 namespace ifile
19 {
20 
21 
26  public QObject,
28  virtual public ifile::IFileListProvider,
30 {
31  Q_OBJECT
32 public:
34 
35  I_BEGIN_COMPONENT(CFileListProviderComp);
36  I_REGISTER_INTERFACE(istd::IChangeable);
37  I_REGISTER_INTERFACE(ifile::IFileListProvider);
38  I_ASSIGN(m_dirParamCompPtr, "DirParam", "Parameter storing root directory", true, "DirParam");
39  I_ASSIGN_TO(m_dirParamModelCompPtr, m_dirParamCompPtr, false);
40  I_ASSIGN(m_fileTypeInfoCompPtr, "FileTypeInfo", "File type info used to create file filters", false, "FileTypeInfo");
41  I_ASSIGN_MULTI_0(m_filtersAttrPtr, "Filters", "List of filters if no loader is specified", false);
42  I_ASSIGN(m_minRecurDepthAttrPtr, "MinRecurDepth", "Minimal recursion depth for file search", true, 0);
43  I_ASSIGN(m_maxRecurDepthAttrPtr, "MaxRecurDepth", "Maximal recursion depth for file search, negative value means no depth limit", true, 0);
44  I_END_COMPONENT;
45 
46  // reimplemented (ifile::IFileListProvider)
47  virtual const QFileInfoList& GetFileList() const;
48 
56  static bool CreateFileList(const QDir& root,
57  int minRecursionDepth,
58  int maxRecursionDepth,
59  const QStringList& nameFilters,
60  QDir::SortFlags sortSpec,
61  QFileInfoList& fileList,
62  istd::ILogger* loggerPtr = NULL);
68  static bool CreateDirectoryList(const QDir& root,
69  int minRecursionDepth,
70  int maxRecursionDepth,
71  const QStringList& nameFilters,
72  QDir::SortFlags sortSpec,
73  QFileInfoList& directoryList,
74  istd::ILogger* loggerPtr = NULL);
75 protected:
76  // reimplemented (imod::CSingleModelObserverBase)
77  virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
78 
79  // reimplemented (icomp::CComponentBase)
80  virtual void OnComponentCreated();
81  virtual void OnComponentDestroyed();
82 
83 private Q_SLOTS:
84  void OnDirectoryContentChanged(const QString& directoryPath);
85 
86 private:
87  static void EnumerateDirectory(
88  const QDir& root,
89  int minRecursionDepth,
90  int maxRecursionDepth,
91  const QStringList& nameFilters,
92  QDir::SortFlags sortSpec,
93  QFileInfoList& directoryList);
94 
95 private:
96  I_REF(ifile::IFileNameParam, m_dirParamCompPtr);
97  I_REF(imod::IModel, m_dirParamModelCompPtr);
98  I_REF(ifile::IFileTypeInfo, m_fileTypeInfoCompPtr);
99  I_MULTIATTR(QString, m_filtersAttrPtr);
100  I_ATTR(int, m_minRecurDepthAttrPtr);
101  I_ATTR(int, m_maxRecurDepthAttrPtr);
102 
103  QFileInfoList m_fileList;
104 
105  QFileSystemWatcher m_directoryWatcher;
106 };
107 
108 
109 } // namespace ifile
110 
111 
112 #endif
113 
114 
Basic implementation for a single model observer.
Provide loading and saving of objects.
Definition: IFileTypeInfo.h:22
Common interface for classes sending some log info.
Definition: ILogger.h:20
virtual void OnComponentDestroyed()
static bool CreateFileList(const QDir &root, int minRecursionDepth, int maxRecursionDepth, const QStringList &nameFilters, QDir::SortFlags sortSpec, QFileInfoList &fileList, istd::ILogger *loggerPtr=NULL)
Creates the list of files in a root directory root.
static bool CreateDirectoryList(const QDir &root, int minRecursionDepth, int maxRecursionDepth, const QStringList &nameFilters, QDir::SortFlags sortSpec, QFileInfoList &directoryList, istd::ILogger *loggerPtr=NULL)
Several filters can be applied to the QDir object before call of this function.
Wrapper provider of log-functionality for component based implementations.
Common interface for any file system item name (e.g directory, file or URL path)
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
virtual const QFileInfoList & GetFileList() const
Get list of files.
#define NULL
Definition: istd.h:64
Provide list of file pathes using recursive search of some file directory.
ilog::CLoggerComponentBase BaseClass
virtual void OnComponentCreated()
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet)
Called on update of observed model.
Provide access to a list of files.

© 2007-2017 Witold Gantzke and Kirill Lepskiy