16 * The source file of the file widget |
16 * The source file of the file widget |
17 * |
17 * |
18 */ |
18 */ |
19 #include "fmfilewidget.h" |
19 #include "fmfilewidget.h" |
20 #include "fmutils.h" |
20 #include "fmutils.h" |
|
21 #include "fmcommon.h" |
21 #include "fmdrivemodel.h" |
22 #include "fmdrivemodel.h" |
22 #include "fmdrivewatcher.h" |
23 #include "fmdrivewatcher.h" |
23 #include "fmcommon.h" |
|
24 #include "fmfileiconprovider.h" |
24 #include "fmfileiconprovider.h" |
|
25 #include "fmfilesystemproxymodel.h" |
25 |
26 |
26 #include "hbstyle.h" |
27 #include "hbstyle.h" |
27 #include "hbabstractitemview.h" |
28 #include "hbabstractitemview.h" |
28 #include <hblistview.h> |
29 #include <hblistview.h> |
29 |
30 |
76 setModel( mDriveModel ); |
78 setModel( mDriveModel ); |
77 FM_LOG( "FmFileWidget::setRootPath set drive model end" ); |
79 FM_LOG( "FmFileWidget::setRootPath set drive model end" ); |
78 emit pathChanged( QString() ); |
80 emit pathChanged( QString() ); |
79 } else { |
81 } else { |
80 FM_LOG( "FmFileWidget::setRootPath set dir model end" ); |
82 FM_LOG( "FmFileWidget::setRootPath set dir model end" ); |
81 setModel( mFileSystemModel ); |
83 setModel( mFileModel ); |
82 FM_LOG( "FmFileWidget::setRootPath set dir model end" ); |
84 FM_LOG( "FmFileWidget::setRootPath set dir model end" ); |
83 mListView->setRootIndex( mFileSystemModel->setRootPath( pathName ) ); |
85 mListView->setRootIndex( mFileModel->setRootPath( pathName ) ); |
84 FM_LOG( "FmFileWidget::setRootPath set rootIndex" ); |
86 FM_LOG( "FmFileWidget::setRootPath set rootIndex" ); |
85 emit pathChanged( pathName ); |
87 emit pathChanged( pathName ); |
86 } |
88 } |
87 FM_LOG( "FmFileWidget::setRootPath end" ); |
89 FM_LOG( "FmFileWidget::setRootPath end" ); |
88 } |
90 } |
103 FM_LOG("FmFileWidget::on_list_activated end becaise checkedpath empty" ); |
105 FM_LOG("FmFileWidget::on_list_activated end becaise checkedpath empty" ); |
104 return; |
106 return; |
105 } |
107 } |
106 |
108 |
107 FM_LOG("FmFileWidget::on_list_activated setModel dir start" ); |
109 FM_LOG("FmFileWidget::on_list_activated setModel dir start" ); |
108 setModel( mFileSystemModel ); |
110 setModel( mFileModel ); |
109 FM_LOG("FmFileWidget::on_list_activated setModel dir end" ); |
111 FM_LOG("FmFileWidget::on_list_activated setModel dir end" ); |
110 setRootPath( checkedPath ); |
112 setRootPath( checkedPath ); |
111 FM_LOG("FmFileWidget::on_list_activated setRootIndex" ); |
113 FM_LOG("FmFileWidget::on_list_activated setRootIndex" ); |
112 emit pathChanged( checkedPath ); |
114 emit pathChanged( checkedPath ); |
113 FM_LOG("FmFileWidget::on_list_activated finish emit pathChanged" ); |
115 FM_LOG("FmFileWidget::on_list_activated finish emit pathChanged" ); |
114 } |
116 } |
115 else if( mCurrentModel == mFileSystemModel ) { |
117 else if( mCurrentModel == mFileModel ) { |
116 //If current model is FileSystemModel, open path or emit file activate signal. |
118 //If current model is FileSystemModel, open path or emit file activate signal. |
117 if ( mFileSystemModel->isDir( mActivatedModelIndex ) ) { |
119 if ( mFileModel->isDir( mActivatedModelIndex ) ) { |
118 FM_LOG("FmFileWidget::on_list_activated start changeRootIndex" ); |
120 FM_LOG("FmFileWidget::on_list_activated start changeRootIndex" ); |
119 changeRootIndex( mActivatedModelIndex ); |
121 changeRootIndex( mActivatedModelIndex ); |
120 FM_LOG("FmFileWidget::on_list_activated finish changeRootIndex" ); |
122 FM_LOG("FmFileWidget::on_list_activated finish changeRootIndex" ); |
121 } else { |
123 } else { |
122 QFileInfo fileInfo( mFileSystemModel->filePath( mActivatedModelIndex ) ); |
124 QFileInfo fileInfo( mFileModel->filePath( mActivatedModelIndex ) ); |
123 if( fileInfo.isFile() ) { |
125 if( fileInfo.isFile() ) { |
124 emit fileActivated( fileInfo.fileName() ); |
126 emit fileActivated( fileInfo.fileName() ); |
125 FM_LOG("FmFileWidget::on_list_activated finish emit fileActivated" ); |
127 FM_LOG("FmFileWidget::on_list_activated finish emit fileActivated" ); |
126 } |
128 } |
127 } |
129 } |
131 FM_LOG("FmFileWidget::on_list_activated end" ); |
133 FM_LOG("FmFileWidget::on_list_activated end" ); |
132 } |
134 } |
133 |
135 |
134 void FmFileWidget::setModelFilter( QDir::Filters filters ) |
136 void FmFileWidget::setModelFilter( QDir::Filters filters ) |
135 { |
137 { |
136 mFileSystemModel->setFilter( filters ); |
138 mFileModel->setFilter( filters ); |
137 } |
139 } |
138 |
140 |
139 void FmFileWidget::setNameFilters( const QStringList &nameFilters ) |
141 void FmFileWidget::setNameFilters( const QStringList &nameFilters ) |
140 { |
142 { |
141 mFileSystemModel->setNameFilters( nameFilters ); |
143 mFileModel->setNameFilters( nameFilters ); |
142 } |
144 } |
143 |
145 |
144 void FmFileWidget::changeRootIndex( const QModelIndex &index ) |
146 void FmFileWidget::changeRootIndex( const QModelIndex &index ) |
145 { |
147 { |
146 FM_LOG("FmFileWidget::changeRootIndex start" ); |
148 FM_LOG("FmFileWidget::changeRootIndex start" ); |
147 if( mCurrentModel != mFileSystemModel ) { |
149 if( mCurrentModel != mFileModel ) { |
148 FM_LOG("FmFileWidget::changeRootIndex end because model not equal mFileSystemModel" ); |
150 FM_LOG("FmFileWidget::changeRootIndex end because model not equal mFileModel" ); |
149 return; |
151 return; |
150 } |
152 } |
151 |
153 |
152 mFileSystemModel->fetchMore(index); |
154 mFileModel->fetchMore(index); |
153 QString filePath = mFileSystemModel->fileInfo( index ).absoluteFilePath(); |
155 QString filePath = mFileModel->fileInfo( index ).absoluteFilePath(); |
154 // pathChanged signal will be emitted in setRootPath |
156 // pathChanged signal will be emitted in setRootPath |
155 setRootPath( filePath ); |
157 setRootPath( filePath ); |
156 FM_LOG("FmFileWidget::changeRootIndex end" ); |
158 FM_LOG("FmFileWidget::changeRootIndex end" ); |
157 } |
159 } |
158 |
160 |
168 |
170 |
169 mDriveModel = new FmDriveModel( this, |
171 mDriveModel = new FmDriveModel( this, |
170 FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume | FmDriveModel::HideUnAvailableDrive ); |
172 FmDriveModel::FillWithVolume | FmDriveModel::FillWithDefaultVolume | FmDriveModel::HideUnAvailableDrive ); |
171 |
173 |
172 qDebug( QTime::currentTime().toString().toUtf8().data() ); |
174 qDebug( QTime::currentTime().toString().toUtf8().data() ); |
173 mFileSystemModel = new QFileSystemModel( this ); |
175 mFileSystemSourceModel = new QFileSystemModel( this ); |
174 mFileIconProvider = new FmFileIconProvider(); |
176 mFileIconProvider = new FmFileIconProvider(); |
175 mFileSystemModel->setIconProvider( mFileIconProvider ); |
177 mFileSystemSourceModel->setIconProvider( mFileIconProvider ); |
176 qDebug("constructed mFileSystemModel"); |
178 qDebug("constructed mFileSystemSourceModel"); |
|
179 |
|
180 |
|
181 mFileModel = new FmFileSystemProxyModel( this ); |
|
182 mFileModel->setSourceModel( mFileSystemSourceModel ); |
|
183 |
177 |
184 |
178 qDebug( QTime::currentTime().toString().toUtf8().data() ); |
185 qDebug( QTime::currentTime().toString().toUtf8().data() ); |
179 setModel( mDriveModel ); |
186 setModel( mDriveModel ); |
180 qDebug("setmodel"); |
187 qDebug("setmodel"); |
181 qDebug( QTime::currentTime().toString().toUtf8().data() ); |
188 qDebug( QTime::currentTime().toString().toUtf8().data() ); |
205 FmFileWidget::ViewType FmFileWidget::currentViewType() |
212 FmFileWidget::ViewType FmFileWidget::currentViewType() |
206 { |
213 { |
207 ViewType viewType = DriveView; |
214 ViewType viewType = DriveView; |
208 if( mCurrentModel == mDriveModel ) { |
215 if( mCurrentModel == mDriveModel ) { |
209 viewType = DriveView; |
216 viewType = DriveView; |
210 } else if( mCurrentModel == mFileSystemModel ) { |
217 } else if( mCurrentModel == mFileModel ) { |
211 viewType = DirView; |
218 viewType = DirView; |
212 } else { |
219 } else { |
213 Q_ASSERT( false ); |
220 Q_ASSERT( false ); |
214 } |
221 } |
215 return viewType; |
222 return viewType; |