20 #define FMVIEWMANAGER_H |
20 #define FMVIEWMANAGER_H |
21 |
21 |
22 #include <QObject> |
22 #include <QObject> |
23 #include <QList> |
23 #include <QList> |
24 #include "fmcommon.h" |
24 #include "fmcommon.h" |
|
25 #include <QPixmap> |
25 |
26 |
26 class FmMainWindow; |
27 class FmMainWindow; |
27 class HbView; |
28 class HbView; |
28 class FmViewManager; |
29 class FmViewManager; |
29 class FmOperationService; |
30 class FmOperationService; |
30 class FmOperationBase; |
31 class FmOperationBase; |
31 class QFileSystemWatcher; |
32 class QFileSystemWatcher; |
32 class FmDriveWatcher; |
33 class FmDriveWatcher; |
33 class HbDialog; |
34 class FmDialog; |
34 |
35 |
|
36 /* |
|
37 * this class is used to record relationship between dialog and drive name |
|
38 * FmViewManager will auto-close dialog which related drive is not available again. |
|
39 * for example. set name to MMC will pop a dialog, if add the dialog to FmViewManager::addDlgCloseUnit |
|
40 * then after eject MMC, the dialog will be auto-closed by FmViewManager::checkDlgCloseUnit() |
|
41 */ |
35 class FmDlgCloseUnit |
42 class FmDlgCloseUnit |
36 { |
43 { |
37 public: |
44 public: |
38 FmDlgCloseUnit( HbDialog *dialog ); |
45 FmDlgCloseUnit( FmDialog *dialog ); |
39 ~FmDlgCloseUnit(); |
46 ~FmDlgCloseUnit(); |
40 |
47 |
41 void addAssociatedDrives( QString drives ); |
48 void addAssociatedDrives( QString drives ); |
42 void removeAssociatedDrives( QString drives ); |
49 void removeAssociatedDrives( QString drives ); |
43 QString associatedDrives(); |
50 QString associatedDrives(); |
44 HbDialog *dialog(); |
51 FmDialog *dialog(); |
45 |
52 |
46 private: |
53 private: |
47 HbDialog *mDialog; |
54 FmDialog *mDialog; |
48 QString mAssociatedDrives; |
55 QString mAssociatedDrives; |
49 }; |
56 }; |
50 |
57 |
51 class FmViewManager : public QObject |
58 class FmViewManager : public QObject |
52 { |
59 { |
67 void createDriverView(); |
74 void createDriverView(); |
68 void createSplitView(); |
75 void createSplitView(); |
69 void createBackupView(); |
76 void createBackupView(); |
70 void createRestoreView(); |
77 void createRestoreView(); |
71 void createDeleteBackupView(); |
78 void createDeleteBackupView(); |
72 |
79 void saveActivity(); |
73 void addWatchPath( const QString &path ); |
80 // add a close unit. this is used to auto-close dialog which related drive is not available again. |
74 void removeWatchPath( const QString &path ); |
|
75 |
|
76 // dialog close utils: |
|
77 void addDlgCloseUnit( FmDlgCloseUnit* unit ) |
81 void addDlgCloseUnit( FmDlgCloseUnit* unit ) |
78 { |
82 { |
79 FmLogger::log( "FmViewManager::addDlgCloseUnit_" + unit->associatedDrives() ); |
83 FM_LOG( "FmViewManager::addDlgCloseUnit_" + unit->associatedDrives() ); |
80 mDlgCloseUnitList.append( unit ); |
84 mDlgCloseUnitList.append( unit ); |
81 } |
85 } |
|
86 |
|
87 // remove a close unit. |
82 void removeDlgCloseUnit( FmDlgCloseUnit* unit ) |
88 void removeDlgCloseUnit( FmDlgCloseUnit* unit ) |
83 { |
89 { |
84 FmLogger::log( "FmViewManager::removeDlgCloseUnit_" + unit->associatedDrives() ); |
90 FM_LOG( "FmViewManager::removeDlgCloseUnit_" + unit->associatedDrives() ); |
85 mDlgCloseUnitList.removeOne( unit ); |
91 mDlgCloseUnitList.removeOne( unit ); |
86 } |
92 } |
87 |
93 |
88 protected: |
94 protected: |
89 explicit FmViewManager( FmMainWindow* mainWindow ); |
95 explicit FmViewManager( FmMainWindow* mainWindow ); |
90 ~FmViewManager(); |
96 ~FmViewManager(); |
91 |
97 |
92 public slots: |
98 public slots: |
93 /// popViewAndShow will delete current view and pop view from stack, then show it. |
99 /// popViewAndShow will delete current view and pop view from stack, then show it. |
94 void popViewAndShow(); |
100 void popViewAndShow(); |
95 void on_operationService_refreshModel( FmOperationBase* operationBase, const QString &path ); |
101 |
96 void on_fsWatcher_fileChanged(const QString &path); |
102 // triggered when drive space is changed |
97 void on_fsWatcher_directoryChanged(const QString &path); |
103 // this slots is used to watch filemanager internal events |
|
104 // drive space event from other applictaion will not be observed here |
|
105 void on_operationService_driveSpaceChanged( FmOperationBase* operationBase ); |
|
106 |
|
107 // triggered when drive is ejected/inserted, or other drive event. it will impact available property |
98 void on_driveWatcher_driveAddedOrChanged(); |
108 void on_driveWatcher_driveAddedOrChanged(); |
|
109 |
|
110 // if operation finished, some addition works( such as refresh... ) should be done in some views |
|
111 // so this is the central controller function |
|
112 void on_operationService_notifyFinish( FmOperationBase *operationBase ); |
|
113 |
|
114 void onAboutToChangeView(HbView * oldView, HbView *newView); |
|
115 |
99 signals: |
116 signals: |
100 void refreshModel( const QString &path ); |
117 // emit when drive space is changed by some operation inside filemanager. |
|
118 void driveSpaceChanged(); |
|
119 |
|
120 // emit when drive is ejected/inserted, this is watched by FmDriveWatcher |
|
121 void driveChanged(); |
|
122 |
|
123 // when backup is created, backup date should be updated. |
|
124 void refreshBackupDate(); |
101 |
125 |
102 private: |
126 private: |
103 /// create view will push current view to stack |
127 // when drive is ejected, this function will be called and exam dialogs in mDlgCloseUnitList |
104 // HbView *createView( FmViewType viewType ); |
128 // it will colse dialogs if related drive is not available |
105 |
|
106 // void adjustSecondarySoftKey(); |
|
107 |
|
108 void checkDlgCloseUnit(); |
129 void checkDlgCloseUnit(); |
109 |
130 |
110 private: |
131 private: |
111 static FmViewManager *mViewManager; |
132 static FmViewManager *mViewManager; |
112 |
133 |
113 private: |
134 private: |
114 FmMainWindow *mMainWindow; |
135 // main window |
|
136 FmMainWindow *mMainWindow; |
|
137 |
|
138 // operation service, used to start operations such as copy, move, delete, format... |
115 FmOperationService *mOperationService; |
139 FmOperationService *mOperationService; |
116 QFileSystemWatcher *mFsWatcher; |
140 |
117 FmDriveWatcher *mDriveWatcher; |
141 // used to watch drive event, for example, eject/insert drive |
|
142 FmDriveWatcher *mDriveWatcher; |
118 |
143 |
|
144 // used to record some dialogs that related to drive |
|
145 // the dialog should be closed in checkDlgCloseUnit if drive is not available |
119 QList<FmDlgCloseUnit*> mDlgCloseUnitList; |
146 QList<FmDlgCloseUnit*> mDlgCloseUnitList; |
|
147 |
|
148 QPixmap mScreenShot; |
120 }; |
149 }; |
121 |
150 |
122 |
151 |
123 |
152 |
124 |
153 |