CFilePreviewGuiComp.h
Go to the documentation of this file.
1 #ifndef ifilegui_CFilePreviewGuiComp_included
2 #define ifilegui_CFilePreviewGuiComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QFileSystemWatcher>
7 #include <QtCore/QTimer>
8 #include <QtCore/QDateTime>
9 #include <QtCore/QFutureWatcher>
10 #if QT_VERSION >= 0x050000
11 #include <QtWidgets/QGraphicsView>
12 #else
13 #include <QtGui/QGraphicsView>
14 #endif
15 
16 // ACF includes
17 #include <ifile/IFilePersistence.h>
18 #include <ifile/IFileNameParam.h>
20 
21 #include <GeneratedFiles/ifilegui/ui_CFilePreviewGuiComp.h>
22 
23 
24 namespace ifilegui
25 {
26 
27 
35  Ui::CFilePreviewGuiComp, ifile::IFileNameParam>
36 {
37  Q_OBJECT
38 
39 public:
41  Ui::CFilePreviewGuiComp, ifile::IFileNameParam> BaseClass;
42 
43  I_BEGIN_COMPONENT(CFilePreviewGuiComp);
44  I_ASSIGN(m_fileLoaderCompPtr, "FileLoader", "Object loader", true, "FileLoader");
45  I_ASSIGN(m_objectFactoryCompPtr, "ObjectFactory", "Factory for creation of data object to be previewed", true, "ObjectFactory");
46  I_ASSIGN(m_currentPreviewObjectCompPtr, "CurrentPreviewObject", "Current object will be copied here if set", false, "CurrentPreviewObject");
47  I_ASSIGN(m_objectObserverCompPtr, "ObjectView", "View component for the object", true, "ObjectView");
48  I_ASSIGN_TO(m_objectGuiCompPtr, m_objectObserverCompPtr, true);
49  I_ASSIGN(m_isAsynchronPreviewGenerationEnabledAttrPtr, "AsynchronPreviewGenerationEnabled", "If enabled, the preview generation will be done in a separate thread", true, true);
50  I_ASSIGN(m_noAvailableLabelAttrPtr, "NoAvailableLabel", "Text used for no available preview state", false, "");
51  I_ASSIGN(m_noAvailableIconPathAttrPtr, "NoAvailableIconPath", "Path to the icon used for no available preview state", false, "");
52  I_END_COMPONENT;
53 
55 
56 protected:
57  // reimplemented (iqtgui::TGuiObserverWrap)
58  virtual void OnGuiModelAttached();
59  virtual void OnGuiModelDetached();
60  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
61 
62  // reimplemented (iqtgui::CGuiComponentBase)
63  virtual void OnGuiCreated();
64  virtual void OnGuiDestroyed();
65  virtual void OnGuiRetranslate();
66 
67  // reimplemented (icomp::CComponentBase)
68  virtual void OnComponentCreated();
69 
70 private Q_SLOTS:
71  void UpdateFilePreview();
72  void OnPreviewGenerationFinished();
73 
74 private:
75  void UpdateObjectFromFile();
76  void ResetPreview();
77 
78 protected:
82  class PreviewWidget : public QGraphicsView
83  {
84  public:
85  explicit PreviewWidget(QWidget *parent = NULL);
86 
87  protected:
88  // reimplemented (QWidget)
89  void resizeEvent(QResizeEvent* eventPtr);
90  };
91 
92 protected:
93  I_REF(ifile::IFilePersistence, m_fileLoaderCompPtr);
94  I_FACT(istd::IChangeable, m_objectFactoryCompPtr);
95  I_REF(imod::IObserver, m_objectObserverCompPtr);
96  I_REF(iqtgui::IGuiObject, m_objectGuiCompPtr);
97  I_REF(istd::IChangeable, m_currentPreviewObjectCompPtr);
98  I_ATTR(bool, m_isAsynchronPreviewGenerationEnabledAttrPtr);
99  I_TEXTATTR(m_noAvailableLabelAttrPtr);
100  I_ATTR(QByteArray, m_noAvailableIconPathAttrPtr);
101 
102  QFileSystemWatcher m_fileSystemObserver;
103 
105  QString m_lastFilePath;
106 
107  QFutureWatcher<void> m_previewGenerationWatcher;
108 
111 
112  QMutex m_mutex;
113 
115  QTimer m_timer;
116 };
117 
118 
119 } // namespace ifilegui
120 
121 
122 #endif // !ifilegui_CFilePreviewGuiComp_included
123 
124 
virtual void OnGuiModelDetached()
Called when model is detached or GUI is destroyed.
virtual void OnGuiRetranslate()
Called from widget event filter when GUI should be retranslated.
virtual void OnGuiCreated()
Called just after GUI is initialized.
istd::TDelPtr< istd::IChangeable > m_previewObjectPtr
istd::TDelPtr< istd::IChangeable > m_workingObjectPtr
virtual void OnGuiModelAttached()
Called when model is attached and GUI is created.
I_TEXTATTR(m_noAvailableLabelAttrPtr)
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
iqtgui::TDesignerGuiObserverCompBase< Ui::CFilePreviewGuiComp, ifile::IFileNameParam > BaseClass
void resizeEvent(QResizeEvent *eventPtr)
Base class for all Qt GUI components.
Common interface for GUI objects using in component context.
Definition: IGuiObject.h:25
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
Do update of the GUI to reflect the state of model.
Component for the preview of the file contents.
#define NULL
Definition: istd.h:64
Helper class to watch after QGraphicsView Resize.
QFileSystemWatcher m_fileSystemObserver
Common interface for all classes implementing the Observer functionality in the Model/Observer design...
Definition: IObserver.h:24
QFutureWatcher< void > m_previewGenerationWatcher
Set of change flags (its IDs).
Definition: IChangeable.h:30
Interface providing loading and saving of data objects.
virtual void OnComponentCreated()
virtual void OnGuiDestroyed()
Called just before GUI is released.

© 2007-2017 Witold Gantzke and Kirill Lepskiy