17 */ |
17 */ |
18 |
18 |
19 #include "fmoperationbase.h" |
19 #include "fmoperationbase.h" |
20 #include "fmdrivedetailstype.h" |
20 #include "fmdrivedetailstype.h" |
21 #include <QtAlgorithms> |
21 #include <QtAlgorithms> |
|
22 /* |
|
23 * \fn void showNote( const QString ¬e ) |
|
24 * This signal is emitted when operation needs operation service to show some note. |
|
25 * \a note indicates the note to show. |
|
26 */ |
22 |
27 |
|
28 /* \fn void notifyWaiting( bool cancelable ) |
|
29 * This signal is emitted when operation needs operation service to wait. |
|
30 * \a cancelable indicates whether it could be canceled. |
|
31 */ |
|
32 |
|
33 /* \fn void notifyPreparing( bool cancelable ) |
|
34 * This signal is emitted when operation needs operation service to prepare. |
|
35 * \a cancelable indicates whether it could be canceled. |
|
36 */ |
|
37 |
|
38 /* \fn void notifyStart( bool cancelable, int maxSteps ) |
|
39 * This signal is emitted when operation starts and operation service shows progress bar. |
|
40 * \a cancelable indicates whether it could be canceled. |
|
41 * \a maxStep indicates the max of progress bar. |
|
42 */ |
|
43 |
|
44 /* \fn void notifyProgress( int currentStep ) |
|
45 * This signal is emitted when operation needs operation service update progress bar. |
|
46 * \a currentStep the current step. |
|
47 */ |
|
48 |
|
49 /* \fn void notifyFinish() |
|
50 * This signal is emitted when operation finished. |
|
51 */ |
|
52 |
|
53 /* \fn void notifyError( int error, const QString &errString ) |
|
54 * This signal is used to notify error. |
|
55 * \a error the error id. |
|
56 * \a errString the error string. |
|
57 */ |
|
58 |
|
59 /* |
|
60 Constructs the base operation with |
|
61 \a parent parent |
|
62 \a operationType the type of current operation. |
|
63 */ |
23 FmOperationBase::FmOperationBase( QObject *parent, FmOperationService::TOperationType operationType ) : |
64 FmOperationBase::FmOperationBase( QObject *parent, FmOperationService::TOperationType operationType ) : |
24 QObject( parent ), mOperationType( operationType ) |
65 QObject( parent ), mOperationType( operationType ) |
25 { |
66 { |
26 } |
67 } |
27 |
68 |
|
69 /* |
|
70 Destructs the operation |
|
71 */ |
28 FmOperationBase::~FmOperationBase() |
72 FmOperationBase::~FmOperationBase() |
29 { |
73 { |
30 |
74 |
31 } |
75 } |
32 |
76 |
|
77 /* |
|
78 Returns the current operation type |
|
79 */ |
33 FmOperationService::TOperationType FmOperationBase::operationType() |
80 FmOperationService::TOperationType FmOperationBase::operationType() |
34 { |
81 { |
35 return mOperationType; |
82 return mOperationType; |
36 } |
83 } |
37 |
84 |
38 |
85 /* |
39 //FmOperationFormat |
86 Starts the operation, called by FmOperationThread. |
40 //FmOperationFormat::FmOperationFormat( QObject *parent, QString mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ), |
87 Use empty implementation because Backup and Restore |
41 // mDriverName( mDriverName ) |
88 are not done within thread, so they will not reimplement |
42 //{ |
89 this function. |
43 //} |
90 \sa FmOperationThread::run |
44 //FmOperationFormat::~FmOperationFormat() |
91 */ |
45 //{ |
92 void FmOperationBase::start( volatile bool */*isStopped*/ ) |
46 //} |
|
47 // |
|
48 //QString FmOperationFormat::driverName() |
|
49 //{ |
|
50 // return mDriverName; |
|
51 //} |
|
52 |
|
53 //FmOperationDriveDetails |
|
54 FmOperationDriveDetails::FmOperationDriveDetails( QObject *parent, QString driverName ) : |
|
55 FmOperationBase( parent, FmOperationService::EOperationTypeDriveDetails ), |
|
56 mDriverName( driverName ) |
|
57 { |
|
58 } |
|
59 FmOperationDriveDetails::~FmOperationDriveDetails() |
|
60 { |
|
61 qDeleteAll(mDetailsSizeList); |
|
62 } |
|
63 |
|
64 QString FmOperationDriveDetails::driverName() |
|
65 { |
|
66 return mDriverName; |
|
67 } |
|
68 |
|
69 QList<FmDriveDetailsSize*> &FmOperationDriveDetails::detailsSizeList() |
|
70 { |
|
71 return mDetailsSizeList; |
|
72 } |
|
73 |
|
74 //FmOperationFolderDetails |
|
75 FmOperationFolderDetails::FmOperationFolderDetails( QObject *parent, const QString folderPath ) : |
|
76 FmOperationBase( parent, FmOperationService::EOperationTypeFolderDetails ), |
|
77 mFolderPath( folderPath ), |
|
78 mNumofSubFolders( 0 ), |
|
79 mNumofFiles( 0 ), |
|
80 mSizeofFolder( 0 ) |
|
81 |
|
82 { |
|
83 } |
|
84 FmOperationFolderDetails::~FmOperationFolderDetails() |
|
85 { |
93 { |
86 |
94 |
87 } |
95 } |
88 |
96 |
89 QString FmOperationFolderDetails::folderPath() |
97 /* |
|
98 Does some additional work before starting the operation. |
|
99 Returns the error number. |
|
100 */ |
|
101 int FmOperationBase::prepare() |
90 { |
102 { |
91 return mFolderPath; |
103 return FmErrNone; |
92 } |
|
93 |
|
94 int &FmOperationFolderDetails::numofSubFolders() |
|
95 { |
|
96 return mNumofSubFolders; |
|
97 } |
|
98 |
|
99 int &FmOperationFolderDetails::numofFiles() |
|
100 { |
|
101 return mNumofFiles; |
|
102 } |
|
103 |
|
104 quint64 &FmOperationFolderDetails::sizeofFolder() |
|
105 { |
|
106 return mSizeofFolder; |
|
107 } |
104 } |
108 |
105 |
109 |
106 |
110 |
107 /* |
|
108 Constructs a backup operation with |
|
109 \a parent parent |
|
110 */ |
111 FmOperationBackup::FmOperationBackup( QObject *parent ) |
111 FmOperationBackup::FmOperationBackup( QObject *parent ) |
112 : FmOperationBase( parent, FmOperationService::EOperationTypeBackup ) |
112 : FmOperationBase( parent, FmOperationService::EOperationTypeBackup ) |
113 { |
113 { |
114 } |
114 } |
115 |
115 |
|
116 |
|
117 /* |
|
118 Destructs the backup operation |
|
119 */ |
116 FmOperationBackup::~FmOperationBackup() |
120 FmOperationBackup::~FmOperationBackup() |
117 { |
121 { |
118 } |
122 } |
119 |
123 |
120 |
124 /* |
|
125 Constructs a restore operation with |
|
126 \a parent parent |
|
127 \a selection the selected backup items |
|
128 */ |
121 FmOperationRestore::FmOperationRestore( QObject *parent, quint64 selection ) |
129 FmOperationRestore::FmOperationRestore( QObject *parent, quint64 selection ) |
122 : FmOperationBase( parent, FmOperationService::EOperationTypeRestore ), mSelection( selection ) |
130 : FmOperationBase( parent, FmOperationService::EOperationTypeRestore ), mSelection( selection ) |
123 { |
131 { |
124 } |
132 } |
125 |
133 |
|
134 /* |
|
135 Destructs the restore operation |
|
136 */ |
126 FmOperationRestore::~FmOperationRestore() |
137 FmOperationRestore::~FmOperationRestore() |
127 { |
138 { |
128 } |
139 } |
129 |
140 |
|
141 /* |
|
142 Returns the backup items |
|
143 */ |
130 quint64 FmOperationRestore::selection() |
144 quint64 FmOperationRestore::selection() |
131 { |
145 { |
132 return mSelection; |
146 return mSelection; |
133 } |
147 } |