CFileDialogLoaderComp.h
Go to the documentation of this file.
1 #ifndef ifilegui_CFileDialogSerializerComp_included
2 #define ifilegui_CFileDialogSerializerComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QFileInfo>
7 #include <QtCore/QString>
8 
9 
10 // ACF includes
11 #include <icomp/CComponentBase.h>
12 #include <ilog/TLoggerCompWrap.h>
13 #include <ifile/IFilePersistence.h>
15 #include <ifile/IFileNameParam.h>
16 #include <ifilegui/ifilegui.h>
17 
18 
19 namespace ifilegui
20 {
21 
28  public QObject,
30  virtual public ifile::IFilePersistence,
31  virtual public ifile::IFilePersistenceInfo
32 {
33 public:
35 
36  enum MessageId
37  {
39  };
40 
41  I_BEGIN_COMPONENT(CFileDialogLoaderComp);
42  I_REGISTER_INTERFACE(ifile::IFileTypeInfo);
43  I_REGISTER_INTERFACE(ifile::IFilePersistence);
44  I_REGISTER_INTERFACE(ifile::IFilePersistenceInfo);
45  I_ASSIGN(m_useNativeAttrPtr, "UseNative", "Use native system file dialog", true, true);
46  I_ASSIGN_MULTI_0(m_loadersCompPtr, "Loaders", "List of file serializers will be used as slaves", true);
47  I_ASSIGN(m_statupDirectoryCompPtr, "StartupDirectory", "Initial directory path for the file loader dialog", false, "StartupDirectory");
48  I_END_COMPONENT;
49 
50  // reimplemented (ifile::IFilePersistence)
51  virtual bool IsOperationSupported(
52  const istd::IChangeable* dataObjectPtr,
53  const QString* filePathPtr = NULL,
54  int flags = -1,
55  bool beQuiet = true) const;
56  virtual int LoadFromFile(
57  istd::IChangeable& data,
58  const QString& filePath = QString(),
59  ibase::IProgressManager* progressManagerPtr = NULL) const;
60  virtual int SaveToFile(
61  const istd::IChangeable& data,
62  const QString& filePath = QString(),
63  ibase::IProgressManager* progressManagerPtr = NULL) const;
64 
65  // reimplemented (ifile::IFileTypeInfo)
66  virtual bool GetFileExtensions(QStringList& result, const istd::IChangeable* dataObjectPtr = NULL, int flags = -1, bool doAppend = false) const;
67  virtual QString GetTypeDescription(const QString* extensionPtr = NULL) const;
68 
69  // reimplemented (ifile::IFilePersistenceInfo)
70  virtual QString GetLastFilePath(OperationType operationType = OT_UNKNOWN, PathType pathType = PT_COMPLETE) const;
71 
72  // static methods
80  static void AppendLoaderFilterList(
81  const ifile::IFileTypeInfo& fileTypeInfo,
82  const istd::IChangeable* dataObjectPtr,
83  int flags,
84  QStringList& allExt,
85  QStringList& result,
86  bool allowCommonDescription = true);
87 
88 protected:
89  QString GetPathForType(const QFileInfo& fileInfo, PathType pathType) const;
90  virtual QString GetFileName(const istd::IChangeable& data, const QString& filePath, bool isSaving, int& selectionIndex) const;
91 
92  ifile::IFilePersistence* GetLoaderFor(const istd::IChangeable* dataObjectPtr, const QString& filePath, int selectionIndex, int flags, bool beQuiet) const;
93 
94  // reimplemented (icomp::CComponentBase)
95  virtual void OnComponentCreated();
96 
97 private:
98  I_ATTR(bool, m_useNativeAttrPtr);
99  I_MULTIREF(ifile::IFilePersistence, m_loadersCompPtr);
100  I_REF(ifile::IFileNameParam, m_statupDirectoryCompPtr);
101 
102  mutable QFileInfo m_lastOpenInfo;
103  mutable QFileInfo m_lastSaveInfo;
104 };
105 
106 
107 } // namespace ifilegui
108 
109 
110 #endif // !ifilegui_CFileDialogSerializerComp_included
111 
Provide loading and saving of objects.
Definition: IFileTypeInfo.h:22
ifile::IFilePersistence * GetLoaderFor(const istd::IChangeable *dataObjectPtr, const QString &filePath, int selectionIndex, int flags, bool beQuiet) const
ilog::CLoggerComponentBase BaseClass
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
static void AppendLoaderFilterList(const ifile::IFileTypeInfo &fileTypeInfo, const istd::IChangeable *dataObjectPtr, int flags, QStringList &allExt, QStringList &result, bool allowCommonDescription=true)
Append filters extracted from file loader to Qt filter list accepted by QFileDialog.
virtual bool IsOperationSupported(const istd::IChangeable *dataObjectPtr, const QString *filePathPtr=NULL, int flags=-1, bool beQuiet=true) const
Returns true if object dataObject can be loaded/saved.
Provide some information about file loader state.
virtual QString GetLastFilePath(OperationType operationType=OT_UNKNOWN, PathType pathType=PT_COMPLETE) const
Returns the last opened file name.
#define NULL
Definition: istd.h:64
virtual int LoadFromFile(istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
This function loads data data from file filePath.
virtual int SaveToFile(const istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
This function saves data data to file filePath.
virtual QString GetTypeDescription(const QString *extensionPtr=NULL) const
Get description of object type associated with single extension.
MessageId
List of possible message IDs used in context of this interface.
virtual bool GetFileExtensions(QStringList &result, const istd::IChangeable *dataObjectPtr=NULL, int flags=-1, bool doAppend=false) const
Get file extensions supported by this loader.
Interface providing loading and saving of data objects.
QString GetPathForType(const QFileInfo &fileInfo, PathType pathType) const
virtual QString GetFileName(const istd::IChangeable &data, const QString &filePath, bool isSaving, int &selectionIndex) const
Consume information about progress of some process.

© 2007-2017 Witold Gantzke and Kirill Lepskiy