--- a/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -31,14 +31,13 @@
FmBackupView::FmBackupView() : FmViewBase( EBackupView )
{
- setTitle( hbTrId( "Backup" ) );
+ setTitle( hbTrId( "Backup" ) );
- initToolBar();
- initMainWidget();
- initMenu();
- mOperationService = FmViewManager::viewManager()->operationService();
+ initToolBar();
+ initMainWidget();
+ initMenu();
+ mOperationService = FmViewManager::viewManager()->operationService();
- QMetaObject::connectSlotsByName( this );
}
FmBackupView::~FmBackupView()
@@ -51,27 +50,29 @@
HbAction *action = 0;
#ifdef FM_CHANGE_ORIENT_ENABLE
- action = new HbAction( this );
+ action = new HbAction( this );
action->setObjectName( "rotateAction" );
action->setText( hbTrId( "Change orientation" ) );
menu()->addAction( action );
+ connect( action, SIGNAL(triggered()), this, SLOT( on_rotateAction_triggered() ), Qt::QueuedConnection );
#endif
- action = new HbAction( this );
+ action = new HbAction( this );
action->setObjectName( "backupAction" );
action->setText( hbTrId( "Start backup" ) );
menu()->addAction( action );
+ connect( action, SIGNAL(triggered()), this, SLOT( on_backupAction_triggered() ), Qt::QueuedConnection );
- action = new HbAction( this );
+ action = new HbAction( this );
action->setObjectName( "deleteBackupAction" );
action->setText( hbTrId( "Delete backup" ) );
menu()->addAction( action );
-
+ connect( action, SIGNAL(triggered()), this, SLOT( on_deleteBackupAction_triggered() ), Qt::QueuedConnection );
}
void FmBackupView::initMainWidget()
{
- mMainWidget = new FmBackupWidget( this );
+ mMainWidget = new FmBackupWidget( this );
setWidget( mMainWidget );
}
@@ -82,6 +83,7 @@
mToolBarAction->setObjectName( "leftAction" );
mToolBarAction->setText( hbTrId("Start backup") );
toolBar()->addAction( mToolBarAction );
+ connect( mToolBarAction, SIGNAL(triggered()), this, SLOT( on_leftAction_triggered() ), Qt::QueuedConnection );
toolBar()->setOrientation( Qt::Horizontal );
}
@@ -89,7 +91,7 @@
void FmBackupView::on_leftAction_triggered()
{
int ret = mOperationService->asyncBackup();
- FmLogger::log( "FmBackupView_asyncBackup: ret= " + QString::number(ret) );
+ FM_LOG( "FmBackupView_asyncBackup: ret= " + QString::number(ret) );
switch( ret )
{
case FmErrNone:
@@ -143,11 +145,7 @@
mMainWidget->updateBackupDate();
}
-void FmBackupView::refreshModel( const QString& path )
+void FmBackupView::refreshModel()
{
- if( !path.isEmpty() ) {
- // ignore non-empty refresh signal as it means change of folder/file, not drive.
- return;
- }
mMainWidget->refreshModel();
}
--- a/filemanager/src/filemanager/src/backuprestore/fmbackupview.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupview.h Fri Jul 23 11:12:24 2010 +0800
@@ -47,7 +47,7 @@
public slots:
void refreshBackupDate();
- void refreshModel( const QString& path );
+ void refreshModel();
private slots:
void on_leftAction_triggered();
--- a/filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -100,7 +100,7 @@
void FmBackupWidget::expandAllGroup()
{
- FmLogger::log( QString( "function expandAllGroup start" ) );
+ FM_LOG( QString( "function expandAllGroup start" ) );
mDataForm->setModel( 0 );
mDataForm->setModel( mModel );
@@ -108,19 +108,19 @@
HbDataFormViewItem *itemScheduling =
(HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mSchedulingGroup)));
if( itemScheduling ){
- FmLogger::log( QString( "expand itemScheduling start" ) );
+ FM_LOG( QString( "expand itemScheduling start" ) );
itemScheduling->setExpanded( true );
- FmLogger::log( QString( "expand itemScheduling end" ) );
+ FM_LOG( QString( "expand itemScheduling end" ) );
}
HbDataFormViewItem *itemGroup =
(HbDataFormViewItem *)(mDataForm->itemByIndex(mModel->indexFromItem(mContentsGroup)));
if( itemGroup ){
- FmLogger::log( QString( "expand itemGroup start" ) );
+ FM_LOG( QString( "expand itemGroup start" ) );
itemGroup->setExpanded( true );
- FmLogger::log( QString( "expand itemGroup end" ) );
+ FM_LOG( QString( "expand itemGroup end" ) );
}
- FmLogger::log( QString( "function expandAllGroup end" ) );
+ FM_LOG( QString( "function expandAllGroup end" ) );
}
void FmBackupWidget::initModel()
--- a/filemanager/src/filemanager/src/backuprestore/fmdeletebackupview.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/backuprestore/fmdeletebackupview.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -37,8 +37,6 @@
initToolBar();
initMenu();
mOperationService = FmViewManager::viewManager()->operationService();
-
- QMetaObject::connectSlotsByName( this );
}
FmDeleteBackupView::~FmDeleteBackupView()
@@ -54,6 +52,7 @@
action->setObjectName( "rotateAction" );
action->setText( hbTrId( "Change orientation" ) );
menu()->addAction( action );
+ connect( action, SIGNAL(triggered()), this, SLOT( on_rotateAction_triggered() ), Qt::QueuedConnection );
#endif
mDeleteAction = new HbAction( this );
@@ -61,6 +60,7 @@
mDeleteAction->setText( hbTrId( "Delete backups" ) );
menu()->addAction( mDeleteAction );
mDeleteAction->setEnabled(false);
+ connect( mDeleteAction, SIGNAL(triggered()), this, SLOT( on_deleteAction_triggered() ), Qt::QueuedConnection );
}
void FmDeleteBackupView::initMainWidget()
@@ -93,6 +93,8 @@
toolBar()->addAction( mLeftAction );
mLeftAction->setEnabled(false);
toolBar()->setOrientation( Qt::Horizontal );
+
+ connect( mLeftAction, SIGNAL(triggered()), this, SLOT( on_leftAction_triggered() ), Qt::QueuedConnection );
}
void FmDeleteBackupView::on_leftAction_triggered()
--- a/filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -37,8 +37,6 @@
initToolBar();
initMenu();
mOperationService = FmViewManager::viewManager()->operationService();
-
- QMetaObject::connectSlotsByName( this );
}
FmRestoreView::~FmRestoreView()
@@ -54,6 +52,7 @@
action->setObjectName( "rotateAction" );
action->setText( hbTrId( "Change orientation" ) );
menu()->addAction( action );
+ connect( action, SIGNAL(triggered()), this, SLOT( on_rotateAction_triggered() ), Qt::QueuedConnection );
#endif
mRestoreAction = new HbAction( this );
@@ -61,6 +60,7 @@
mRestoreAction->setText( hbTrId( "Restore data" ) );
menu()->addAction( mRestoreAction );
mRestoreAction->setEnabled(false);
+ connect( mRestoreAction, SIGNAL(triggered()), this, SLOT( on_restoreAction_triggered() ), Qt::QueuedConnection );
}
void FmRestoreView::initMainWidget()
@@ -78,6 +78,8 @@
mLeftAction->setObjectName( "leftAction" );
mLeftAction->setText( hbTrId( "Restore" ) );
toolBar()->addAction( mLeftAction );
+ connect( mLeftAction, SIGNAL(triggered()), this, SLOT( on_leftAction_triggered() ), Qt::QueuedConnection );
+
mLeftAction->setEnabled(false);
toolBar()->setOrientation( Qt::Horizontal );
}
--- a/filemanager/src/filemanager/src/components/fmdlgutils.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/components/fmdlgutils.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -45,7 +45,7 @@
for( int i = 0; i < associatedDrives.length(); i++ ) {
QString drive( associatedDrives[i] + QString( ":/" ) );
if( !FmUtils::isDriveAvailable( drive ) ) {
- FmLogger::log( "executeDialog return 0_ " + associatedDrives );
+ FM_LOG( "executeDialog return 0_ " + associatedDrives );
return 0;
}
}
--- a/filemanager/src/filemanager/src/components/fmdrivedetailstype.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/components/fmdrivedetailstype.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -17,197 +17,116 @@
*/
#include "fmdrivedetailstype.h"
+#include "fmfiletyperecognizer.h"
#include "fmutils.h"
#include <QDir>
#include <QFileInfo>
#include <QStringList>
-QList<FmDriveDetailsDataGroup*> FmDriveDetailsContent::queryDetailsContent()
-{
- QStringList typeFilters;
- QList< FmDriveDetailsDataGroup* > dataGroupList;
- typeFilters.append( QString( "*.bmp" ) );
- typeFilters.append( QString( "*.gif" ) );
- typeFilters.append( QString( "*.jpe" ) );
- typeFilters.append( QString( "*.jpeg" ) );
- typeFilters.append( QString( "*.jpg" ) );
- typeFilters.append( QString( "*.ota" ) );
- typeFilters.append( QString( "*.png" ) );
- typeFilters.append( QString( "*.tif" ) );
- typeFilters.append( QString( "*.tiff" ) );
- typeFilters.append( QString( "*.wbmp" ) );
- typeFilters.append( QString( "*.wmf" ) );
- typeFilters.append( QString( "*.jp2" ) );
- typeFilters.append( QString( "*.jpg2" ) );
- typeFilters.append( QString( "*.jp3" ) );
- typeFilters.append( QString( "*.ico" ) );
- typeFilters.append( QString( "*.vcf" ) );
-
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupImages,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeExtName ));
-
- typeFilters.clear();
- typeFilters.append( QString( "*.aac" ) );
- typeFilters.append( QString( "*.amr" ) );
- typeFilters.append( QString( "*.au" ) );
- typeFilters.append( QString( "*.awb" ) );
- typeFilters.append( QString( "*.mid" ) );
- typeFilters.append( QString( "*.mp3" ) );
- typeFilters.append( QString( "*.ra" ) );
- typeFilters.append( QString( "*.rmf" ) );
- typeFilters.append( QString( "*.rng" ) );
- typeFilters.append( QString( "*.snd" ) );
- typeFilters.append( QString( "*.wav" ) );
- typeFilters.append( QString( "*.wve" ) );
- typeFilters.append( QString( "*.wma" ) );
- typeFilters.append( QString( "*.m4a" ) );
- typeFilters.append( QString( "*.ott" ) );
- typeFilters.append( QString( "*.mxmf" ) );
-
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupSoundFiles,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeExtName ));
-
- typeFilters.clear();
- typeFilters.append( QString( "*.jad" ) );
- typeFilters.append( QString( "*.jar" ) );
-
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupMidpJava,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeExtName ));
-
- typeFilters.clear();
- typeFilters.append( QString( "*.sis" ) );
- typeFilters.append( QString( "*.sisx" ) );
-
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupNativeApps,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeExtName ));
-
- typeFilters.clear();
- typeFilters.append( QString( "*.3gp" ) );
- typeFilters.append( QString( "*.mp4" ) );
- typeFilters.append( QString( "*.nim" ) );
- typeFilters.append( QString( "*.rm" ) );
- typeFilters.append( QString( "*.rv" ) );
- typeFilters.append( QString( "*.wmv" ) );
- typeFilters.append( QString( "*.3g2" ) );
- typeFilters.append( QString( "*.rmvb") );
- typeFilters.append( QString( "*.mkv" ) );
-
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupVideos,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeExtName ));
-
- typeFilters.clear();
- typeFilters.append( QString( "*.doc" ) );
- typeFilters.append( QString( "*.pdf" ) );
- typeFilters.append( QString( "*.pps" ) );
- typeFilters.append( QString( "*.ppt" ) );
- typeFilters.append( QString( "*.txt" ) );
- typeFilters.append( QString( "*.xls" ) );
-
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupDocuments,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeExtName ));
-
- typeFilters.clear();
- typeFilters.append( QString( "*.vcs" ) );
-
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupCalendar,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeExtName ));
-
- // Add absolute path and use EDataRecognizeAbsolutePath method for Contacts
- typeFilters.clear();
- typeFilters.append( QString( FmViewDetail_Contacts ) );
- dataGroupList.append( new FmDriveDetailsDataGroup( FmDriveDetailsDataGroup::EGroupContacts,
- typeFilters, FmDriveDetailsDataGroup::EDataRecognizeAbsolutePath ));
- return dataGroupList;
-
-}
-
int FmDriveDetailsContent::querySizeofContent( const QString &driveName,
QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped )
{
int err = FmErrNone;
- QList< FmDriveDetailsDataGroup* > dataGroupList = queryDetailsContent();
detailsSizeList.clear();
- for( QList< FmDriveDetailsDataGroup* >::iterator it = dataGroupList.begin();
- it!= dataGroupList.end(); ++it ) {
- if ( *isStopped ){
- return FmErrCancel;
+ err = getDataSizeByTraversePath( driveName, detailsSizeList, isStopped );
+ if( err != FmErrNone ) {
+ return err;
+ }
+
+ QStringList dataPathList;
+ dataPathList.append( QString( FmViewDetail_Contacts ) );
+ FmDriveDetailsDataGroup driveDetailsDataGroup( FmDriveDetailsSize::ETypeContacts, dataPathList );
+
+ err = getDataSizeByAbsolutePath(driveName, driveDetailsDataGroup, detailsSizeList, isStopped);
+ if( err != FmErrNone ) {
+ return err;
+ }
+
+ return FmErrNone;
+}
+int FmDriveDetailsContent::getDataSizeByTraversePath( const QString &driveName,
+ QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped )
+{
+ qint64 imageSize( 0 );
+ qint64 soundSize( 0 );
+ qint64 midpJavaSize( 0 );
+ qint64 nativeAppsSize( 0 );
+ qint64 videoSize( 0 );
+ qint64 documentsSize( 0 );
+
+ FmFileTypeRecognizer fileTypeRecognizer;
+
+ QList<QDir> dirs;
+ dirs.append( QDir( driveName ) );
+
+ // traverse the whole drive
+ while (!dirs.isEmpty()) {
+ QDir::Filters filter = QDir::NoDotAndDotDot | QDir::AllEntries;
+ // do not summarize system and hidden files, these size will go into others category
+ // if( isSysHiddenIncluded ) {
+ // filter = filter | QDir::Hidden | QDir::System;
+ // }
+
+ QFileInfoList infoList = dirs.first().entryInfoList( filter );
+ for ( QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); ++it ) {
+ if ( *isStopped ){
+ return FmErrCancel;
+ }
+
+ if ( it->isFile() ) {
+ FmFileTypeRecognizer::FileType fileType =
+ fileTypeRecognizer.getType( it->absoluteFilePath() );
+ switch ( fileType )
+ {
+ case FmFileTypeRecognizer::FileTypeImage:
+ imageSize += it->size();
+ break;
+ case FmFileTypeRecognizer::FileTypeTone:
+ soundSize += it->size();
+ break;
+ case FmFileTypeRecognizer::FileTypeJava:
+ midpJavaSize += it->size();
+ break;
+ case FmFileTypeRecognizer::FileTypeSisx:
+ nativeAppsSize += it->size();
+ break;
+ case FmFileTypeRecognizer::FileTypeVideo:
+ videoSize += it->size();
+ break;
+ case FmFileTypeRecognizer::FileTypeText:
+ documentsSize += it->size();
+ break;
+ default:
+ // do not need handle other type
+ break;
+ }
+ }
+ else if ( it->isDir() ) {
+ dirs.append( QDir( it->absoluteFilePath() ) );
+ }
}
- FmDriveDetailsDataGroup* driveDetailsDataGroup = *it;
-
- switch( (*it)->dataRecognizeType() )
- {
- case FmDriveDetailsDataGroup::EDataRecognizeExtName:
- err = getDataSizeByExtName(driveName, driveDetailsDataGroup, detailsSizeList, isStopped) ;
- break;
- case FmDriveDetailsDataGroup::EDataRecognizeAbsolutePath:
- err = getDataSizeByAbsolutePath(driveName, driveDetailsDataGroup, detailsSizeList, isStopped);
- break;
- default:
- Q_ASSERT_X( false, "querySizeofContent", "please handle all recognize methods ");
- break;
- }
-
- // return if error occur.
- if( err != FmErrNone ) {
- return err;
- }
+ dirs.removeFirst();
}
+
+ // store result to detailsSizeList.
+ detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeImages, imageSize ) ) ;
+ detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeSoundFiles, soundSize ) );
+ detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeMidpJava, midpJavaSize ) );
+ detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeNativeApps, nativeAppsSize ) );
+ detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeVideos, videoSize ) );
+ detailsSizeList.append( new FmDriveDetailsSize( FmDriveDetailsSize::ETypeDocuments, documentsSize ) );
return FmErrNone;
}
-int FmDriveDetailsContent::getDataSizeByExtName( const QString &driveName,
- const FmDriveDetailsDataGroup* const dataGroup,
- QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped )
-{
- quint64 totalSize = 0;
- QString path;
- path.clear();
-
- if( FmUtils::isDriveC( driveName )){
- path = QString( "c:\\Data\\" );
- }
- else{
- path = driveName;
- }
- QStringList typeFilter = dataGroup->typeFilters();
- QList<QDir> dirs;
- dirs.append( QDir( path ) );
- while (!dirs.isEmpty()) {
- QFileInfoList infoList = dirs.first().entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries );
- QFileInfoList filterInforList = dirs.first().entryInfoList( typeFilter, QDir::NoDotAndDotDot | QDir::Files );
-
- for ( QFileInfoList::Iterator it = filterInforList.begin(); it != filterInforList.end(); ++it ) {
- if ( *isStopped ){
- return FmErrCancel;
- }
- if ( it->isFile() ) {
- totalSize += it->size();
- }
- }
- for ( QFileInfoList::Iterator it = infoList.begin(); it != infoList.end(); ++it ) {
- if ( *isStopped ){
- return FmErrCancel;
- }
- if ( it->isDir() ) {
- dirs.append( QDir( it->absoluteFilePath() ) );
- }
- }
- dirs.removeFirst();
- }
- detailsSizeList.append( new FmDriveDetailsSize( dataGroup->dataGroups(), totalSize ) );
- return FmErrNone;
-
-}
-
int FmDriveDetailsContent::getDataSizeByAbsolutePath( const QString &driveName,
- const FmDriveDetailsDataGroup* const dataGroup,
+ const FmDriveDetailsDataGroup &dataGroup,
QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped )
{
quint64 totalSize = 0;
- QStringList typeFilter = dataGroup->typeFilters();
+ QStringList typeFilter = dataGroup.pathList();
- for( QStringList::iterator it = typeFilter.begin();
+ for( QStringList::const_iterator it = typeFilter.begin();
it!= typeFilter.end(); ++it ) {
if ( *isStopped ){
return FmErrCancel;
@@ -219,7 +138,7 @@
}
}
- detailsSizeList.append( new FmDriveDetailsSize( dataGroup->dataGroups(), totalSize ) );
+ detailsSizeList.append( new FmDriveDetailsSize( dataGroup.dataType(), totalSize ) );
return FmErrNone;
}
@@ -284,7 +203,7 @@
}
QFileInfoList infoList = dirs.first().entryInfoList( filter );
- for ( QFileInfoList::Iterator it = infoList.begin(); it != infoList.end(); ++it ) {
+ for ( QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); ++it ) {
if ( *isStopped ){
return FmErrCancel;
}
--- a/filemanager/src/filemanager/src/components/fmdrivedetailstype.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/components/fmdrivedetailstype.h Fri Jul 23 11:12:24 2010 +0800
@@ -23,63 +23,29 @@
#include <QList>
#include <QStringList>
-class FmDriveDetailsDataGroup
-{
-public:
- // used to identify recognize method
- enum TDataRecognizeType{
- EDataRecognizeExtName = 0, // recognize data by extension of filename
- EDataRecognizeAbsolutePath // recognize data by ablsolute file path
- };
-
- enum TDataGroups{
- EGroupImages = 0,
- EGroupSoundFiles,
- EGroupMidpJava,
- EGroupNativeApps,
- EGroupVideos,
- EGroupDocuments,
- EGroupCalendar,
- EGroupContacts,
- EGroupMessages,
- EGroupOthers
- };
-
-public:
- FmDriveDetailsDataGroup( TDataGroups dataGroups,
- QStringList typeFilters,
- TDataRecognizeType recognizeType )
- : mDataGroups( dataGroups ), mTypeFilters( typeFilters ),
- mDataRecognizeType( recognizeType )
- {
- }
- FmDriveDetailsDataGroup( const FmDriveDetailsDataGroup &other )
- {
- *this = other;
- }
-
- FmDriveDetailsDataGroup &operator= ( const FmDriveDetailsDataGroup &rhs )
- {
- this->mDataGroups = rhs.mDataGroups;
- this->mTypeFilters = rhs.mTypeFilters;
- return *this;
- }
-
- TDataGroups dataGroups() const { return mDataGroups; }
- QStringList typeFilters() const { return mTypeFilters; }
- TDataRecognizeType dataRecognizeType() const { return mDataRecognizeType; }
-
-private:
- TDataGroups mDataGroups;
- QStringList mTypeFilters;
- TDataRecognizeType mDataRecognizeType;
-};
-
+/*
+ \class FmDriveDetailsSize
+ \brief The class FmDriveDetailsSize used to store view details result.
+ */
class FmDriveDetailsSize
{
public:
- FmDriveDetailsSize( FmDriveDetailsDataGroup::TDataGroups dataGroups, quint64 size )
- : mDataGroups( dataGroups ), mSize( size ) {}
+ enum TDataType{
+ ETypeImages = 0,
+ ETypeSoundFiles,
+ ETypeMidpJava,
+ ETypeNativeApps,
+ ETypeVideos,
+ ETypeDocuments,
+ ETypeCalendar,
+ ETypeContacts,
+ ETypeMessages,
+ ETypeOthers
+ };
+
+public:
+ FmDriveDetailsSize( TDataType dataType, quint64 size )
+ : mDataType( dataType ), mSize( size ) {}
FmDriveDetailsSize( const FmDriveDetailsSize &other )
{
*this = other;
@@ -87,45 +53,109 @@
FmDriveDetailsSize &operator= ( const FmDriveDetailsSize &rhs )
{
- this->mDataGroups = rhs.mDataGroups;
+ this->mDataType = rhs.mDataType;
this->mSize = rhs.mSize;
return *this;
}
- FmDriveDetailsDataGroup::TDataGroups dataGroups() const { return mDataGroups; }
+ /*!
+ request the stored data type
+ */
+ TDataType dataType() const { return mDataType; }
+
+ /*!
+ request the stored size that related to data type
+ */
quint64 size() const { return mSize; }
private:
- FmDriveDetailsDataGroup::TDataGroups mDataGroups;
+ /*!
+ store the data type
+ */
+ TDataType mDataType;
+
+ /*!
+ store the size that related to mDataType
+ */
quint64 mSize;
};
+/*
+ \class FmDriveDetailsDataGroup
+ \brief The class FmDriveDetailsDataGroup used to store command of get size of absolute file path.
+ */
+class FmDriveDetailsDataGroup
+{
+public:
+ FmDriveDetailsDataGroup( FmDriveDetailsSize::TDataType dataType,
+ QStringList filePathList )
+ : mDataType( dataType ), mFilePath( filePathList )
+ {
+ }
+ FmDriveDetailsDataGroup( const FmDriveDetailsDataGroup &other )
+ {
+ *this = other;
+ }
+
+ FmDriveDetailsDataGroup &operator= ( const FmDriveDetailsDataGroup &rhs )
+ {
+ this->mDataType = rhs.mDataType;
+ this->mFilePath = rhs.mFilePath;
+ return *this;
+ }
+
+ FmDriveDetailsSize::TDataType dataType() const { return mDataType; }
+ QStringList pathList() const { return mFilePath; }
+private:
+ /*!
+ Store which data type does mFilePath belong to.
+ */
+ FmDriveDetailsSize::TDataType mDataType;
+
+ /*!
+ Store absolute file path that will used to calcuate whole data size related to mDataType
+ */
+ QStringList mFilePath;
+};
+
+/*
+ \class FmDriveDetailsContent
+ \brief The class FmDriveDetailsContent is the interface of view details feature
+ */
class FmDriveDetailsContent
{
public:
- static QList<FmDriveDetailsDataGroup*> queryDetailsContent();
+ /*!
+ Gets data size for drive
+ \a driveName which drive is searching
+ \a detailsSizeList if got result, new FmDriveDetailsSize will be appended to detailsSizeList
+ \a isStopped isStopped will be set as true if user cancel this operation
+ return Filemanage wide error. Please refer to fmdefine.h
+ */
static int querySizeofContent(
const QString &driveName, QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped );
- /**
- * Gets data size for single FmDriveDetailsDataGroup, the method is scan files for extension.
- * @param driveName which drive is searching
- * @param dataGroup which dataGroup is searching, for example, EGroupImages, EGroupSoundFiles...
- * @param detailsSizeList if got result, new FmDriveDetailsSize will be appended to detailsSizeList
- * @param isStopped isStopped will be set as true if user cancel this operation
- * @return Filemanage wide error. Please refer to fmdefine.h
+
+private:
+ /*!
+ Gets data size(related to file type,e.g. image, sound) by traverse designated drive name.
+ provide size except the path related to absolute path(getDataSizeByAbsolutePath)
+ \sa driveName which drive is searching
+ \a detailsSizeList if got result, new FmDriveDetailsSize will be appended to detailsSizeList
+ \a isStopped isStopped will be set as true if user cancel this operation
+ return Filemanage wide error. Please refer to fmdefine.h
*/
- static int getDataSizeByExtName( const QString &driveName, const FmDriveDetailsDataGroup* const dataGroup,
- QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped );
+ static int getDataSizeByTraversePath( const QString &driveName,
+ QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped );
- /**
- * Gets data size for single FmDriveDetailsDataGroup, the method is find file of absolute path
- * @param driveName which drive is searching
- * @param dataGroup which dataGroup is searching, for example, EGroupContacts...
- * @param detailsSizeList if got result, new FmDriveDetailsSize will be appended to detailsSizeList
- * @param isStopped isStopped will be set as true if user cancel this operation
- * @return Filemanage wide error. Please refer to fmdefine.h
+ /*!
+ Gets data size for single FmDriveDetailsDataGroup, the method is find file of absolute path
+ \a driveName which drive is searching
+ \a dataGroup which dataGroup is searching, for example, EGroupContacts...
+ \a detailsSizeList if got result, new FmDriveDetailsSize will be appended to detailsSizeList
+ \a isStopped isStopped will be set as true if user cancel this operation
+ return Filemanage wide error. Please refer to fmdefine.h
*/
- static int getDataSizeByAbsolutePath( const QString &driveName, const FmDriveDetailsDataGroup* const dataGroup,
+ static int getDataSizeByAbsolutePath( const QString &driveName, const FmDriveDetailsDataGroup &dataGroup,
QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped );
};
@@ -133,14 +163,31 @@
{
public:
+ /*!
+ Gets details for a list of folders
+ \a folderPathList folder path list
+ \a numofFolders output how many folders and subfolders in the list
+ \a numofFiles output how many files in the list
+ \a totalSize output the total size
+ \a isStopped isStopped will be set as true if user cancel this operation
+ \a isSysHiddenIncluded will add QDir::Hidden | QDir::System into filter if true
+ return Filemanage wide error. Please refer to fmdefine.h
+ */
static int queryDetailOfContentList( const QStringList folderPathList,int &numofFolders,
int &numofFiles, quint64 &totalSize, volatile bool *isStopped, bool isSysHiddenIncluded = false );
-
+ /*!
+ Gets details for a folder
+ \a folderPath path of the folder
+ \a numofSubFolders output how many subfolders in the list, not include itself
+ \a numofFiles output how many files in the folder
+ \a sizeofFolder output the size of folder
+ \a isStopped isStopped will be set as true if user cancel this operation
+ \a isSysHiddenIncluded will add QDir::Hidden | QDir::System into filter if true
+ return Filemanage wide error. Please refer to fmdefine.h
+ */
static int getNumofSubfolders( const QString &folderPath, int &numofSubFolders,
int &numofFiles, quint64 &sizeofFolder,
volatile bool *isStopped, bool isSysHiddenIncluded = false );
-
-
};
#endif /* FMDRIVEDETAILSTYPE_H */
--- a/filemanager/src/filemanager/src/components/fmviewdetailsdialog.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/components/fmviewdetailsdialog.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -287,46 +287,46 @@
mSizeofCalendar = 0;
mSizeofContacts = 0;
- for( QList< FmDriveDetailsSize* >::iterator it = detailsSizeList.begin();
+ for( QList< FmDriveDetailsSize* >::const_iterator it = detailsSizeList.begin();
it!= detailsSizeList.end(); ++it ){
- switch( ( *it )->dataGroups() ){
- case FmDriveDetailsDataGroup::EGroupImages:
+ switch( ( *it )->dataType() ){
+ case FmDriveDetailsSize::ETypeImages:
{
mSizeofImage = ( *it )->size();
break;
}
- case FmDriveDetailsDataGroup::EGroupSoundFiles:
+ case FmDriveDetailsSize::ETypeSoundFiles:
{
mSizeofSounds = ( *it )->size();
break;
}
- case FmDriveDetailsDataGroup::EGroupMidpJava:
+ case FmDriveDetailsSize::ETypeMidpJava:
{
mSizeofJava = ( *it )->size();
break;
}
- case FmDriveDetailsDataGroup::EGroupNativeApps:
+ case FmDriveDetailsSize::ETypeNativeApps:
{
mSizeofNativeFiles = ( *it )->size();
break;
}
- case FmDriveDetailsDataGroup::EGroupVideos:
+ case FmDriveDetailsSize::ETypeVideos:
{
mSizeofVideo = ( *it )->size();
break;
}
- case FmDriveDetailsDataGroup::EGroupDocuments:
+ case FmDriveDetailsSize::ETypeDocuments:
{
mSizeofDocument = ( *it )->size();
break;
}
- case FmDriveDetailsDataGroup::EGroupCalendar:
+ case FmDriveDetailsSize::ETypeCalendar:
{
mSizeofCalendar = ( *it )->size();
break;
}
- case FmDriveDetailsDataGroup::EGroupContacts:
+ case FmDriveDetailsSize::ETypeContacts:
{
mSizeofContacts = ( *it )->size();
break;
@@ -342,7 +342,7 @@
for( int i = 0; i < associatedDrives.length(); i++ ) {
QString drive( associatedDrives[i] + QString( ":/" ) );
if( !FmUtils::isDriveAvailable( drive ) ) {
- FmLogger::log( "executeDialog return 0_ " + associatedDrives );
+ FM_LOG( "executeDialog return 0_ " + associatedDrives );
return 0;
}
}
@@ -351,9 +351,9 @@
dlgCloseUnit.addAssociatedDrives( associatedDrives );
FmViewManager::viewManager()->addDlgCloseUnit( &dlgCloseUnit );
- FmLogger::log( " Exec Dialog start " );
+ FM_LOG( " Exec Dialog start " );
HbAction* action = dialog->exec();
- FmLogger::log( " Exec Dialog end " );
+ FM_LOG( " Exec Dialog end " );
FmViewManager::viewManager()->removeDlgCloseUnit( &dlgCloseUnit );
return action;
}
@@ -361,7 +361,7 @@
void FmViewDetailsDialog::showDriveViewDetailsDialog( const QString &driverName,
QList<FmDriveDetailsSize*> detailsSizeList, const QString& associatedDrives )
{
- FmLogger::log( "showDriveViewDetailsDialog_" + associatedDrives );
+ FM_LOG( "showDriveViewDetailsDialog_" + associatedDrives );
FmViewDetailsDialog viewDetailsDialog;
viewDetailsDialog.setSizeofContent( detailsSizeList );
--- a/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -58,12 +58,12 @@
void FmDriverListWidget::on_list_activated( const QModelIndex &index )
{
- FmLogger::log("FmDriverListWidget::on_list_activated");
+ FM_LOG("FmDriverListWidget::on_list_activated");
if( mListLongPressed ) {
- FmLogger::log("FmDriverListWidget::on_list_activated return because long pressed");
+ FM_LOG("FmDriverListWidget::on_list_activated return because long pressed");
return;
}
- FmLogger::log("FmDriverListWidget::on_list_activated emit activate to open drive");
+ FM_LOG("FmDriverListWidget::on_list_activated emit activate to open drive");
emit activated( mModel->driveName( index ) );
}
@@ -109,15 +109,14 @@
setLayout( mLayout );
}
-void FmDriverListWidget::refreshModel( const QString &path )
+void FmDriverListWidget::refreshDrive()
{
- Q_UNUSED( path );
mModel->refresh();
}
void FmDriverListWidget::on_list_longPressed( HbAbstractViewItem *item, const QPointF &coords )
{
- FmLogger::log("FmDriverListWidget::on_list_longPressed");
+ FM_LOG("FmDriverListWidget::on_list_longPressed");
mListLongPressed = true;
mCurrentItem = item;
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
--- a/filemanager/src/filemanager/src/fmdriverlistwidget.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmdriverlistwidget.h Fri Jul 23 11:12:24 2010 +0800
@@ -41,7 +41,7 @@
public:
int updatePwd( const QString& oldPwd, const QString& pwd);
- void refreshModel( const QString &path );
+ void refreshDrive();
void activeSearchPanel();
signals:
--- a/filemanager/src/filemanager/src/fmdriverview.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmdriverview.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -31,7 +31,7 @@
FmDriverView::FmDriverView() : FmViewBase( EDriverView )
{
- FmLogger::log( "FmDriverView::FmDriverView" );
+ FM_LOG( "FmDriverView::FmDriverView" );
initMenu();
initToolBar();
initDiskListWidget();
@@ -109,13 +109,11 @@
FmViewManager::viewManager()->createFileView( pathName );
}
-void FmDriverView::refreshModel( const QString &path )
+void FmDriverView::refreshDrive()
{
- FmLogger::log( QString( "FmDriverView::refreshModel start" ) );
- QString logstring = QString( "Refresh Path:" );
- logstring.append( path );
- mDriverList->refreshModel( path );
- FmLogger::log( QString( "FmDriverView::refreshModel end" ) );
+ FM_LOG( QString( "FmDriverView::refreshDrive start" ) );
+ mDriverList->refreshDrive();
+ FM_LOG( QString( "FmDriverView::refreshDrive end" ) );
}
void FmDriverView::on_leftAction_triggered()
--- a/filemanager/src/filemanager/src/fmdriverview.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmdriverview.h Fri Jul 23 11:12:24 2010 +0800
@@ -43,7 +43,7 @@
void on_findAction_triggered();
void activated( const QString &pathName );
- void refreshModel( const QString &path );
+ void refreshDrive();
void startSearch( const QString &targetPath, const QString &criteria );
#ifdef FM_CHANGE_ORIENT_ENABLE
--- a/filemanager/src/filemanager/src/fmfilebrowsewidget.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -120,7 +120,7 @@
void FmFileBrowseWidget::setRootPath( const QString &pathName )
{
QString logString = "FmFileBrowseWidget::setRootPath(" + pathName + ')';
- FmLogger::log( logString );
+ FM_LOG( logString );
int err = checkPathAndSetStyle( pathName );
switch( err )
@@ -250,16 +250,16 @@
void FmFileBrowseWidget::on_listActivated()
{
- FmLogger::log("FmFileBrowseWidget::on_listActivated start");
+ FM_LOG("FmFileBrowseWidget::on_listActivated start");
if( mListLongPressed ) {
- FmLogger::log("FmFileBrowseWidget::on_list_activated end because longPressed");
+ FM_LOG("FmFileBrowseWidget::on_list_activated end because longPressed");
return;
}
if (!mSelectable) {
if (mModel->isDir(mActivatedModelIndex) ) {
- FmLogger::log("FmFileBrowseWidget::on_list_activated changeRootIndex>>");
+ FM_LOG("FmFileBrowseWidget::on_list_activated changeRootIndex>>");
changeRootIndex( mActivatedModelIndex );
- FmLogger::log("FmFileBrowseWidget::on_list_activated changeRootIndex<<");
+ FM_LOG("FmFileBrowseWidget::on_list_activated changeRootIndex<<");
} else {
QString filePath( mModel->filePath( mActivatedModelIndex ) );
QFileInfo fileInfo( filePath );
@@ -268,7 +268,7 @@
}
}
}
- FmLogger::log("FmFileBrowseWidget::on_listActivated end");
+ FM_LOG("FmFileBrowseWidget::on_listActivated end");
}
void FmFileBrowseWidget::on_tree_activated( const QModelIndex &index )
@@ -475,34 +475,25 @@
mModel->setFilter( filters );
}
-void FmFileBrowseWidget::refreshModel( const QString& path )
+void FmFileBrowseWidget::on_driveChanged()
{
- FmLogger::log( "FmFileBrowseWidget::refreshModel start" );
- // This slot will be triggered when drive inserted/ejected
- // Because filemanger do not notify dir/files changed yet( QFileSystem will auto refresh.)
+ FM_LOG( "FmFileBrowseWidget::on_driveChanged start" );
QString currPath( currentPath().absoluteFilePath() );
- if( currPath.isEmpty() ) {
- // label style and no data shown( dirve is not present or locked, or corrupt )
-
- //set path as drive root, cause refresh, so that data can be shown when insert MMC in device.
+ if(style()==ListStyle) {
+ // display normally, setRootPath again to check if drive is available
+ setRootPath( currPath );
+ } else{
+ // display label style, setRootPath to drive root
setRootPath( mCurrentDrive );
- // update title
- } else {
- // display drive data normally
- // ignore path refresh event as QFileSystemModel will auto refresh.
-
- // Handle drive refresh event as drive may be ejected.
- if( path.isEmpty() ) { // path is empty means drive is changed.
- checkPathAndSetStyle( currPath );
- }
}
emit setTitle( FmUtils::fillDriveVolume( mCurrentDrive, true ) );
- FmLogger::log( "FmFileBrowseWidget::refreshModel end" );
+ FM_LOG( "FmFileBrowseWidget::on_driveChanged end" );
}
int FmFileBrowseWidget::checkPathAndSetStyle( const QString& path )
{
+ FM_LOG( "FmFileBrowseWidget::checkPathAndSetStyle start_" + path );
int err = FmUtils::isPathAccessabel( path );
switch( err )
{
@@ -736,7 +727,10 @@
FmDlgUtils::information( hbTrId("Rename failed!") );
}
else {
- if ( oldSuffix != newFileInfo.suffix() ) {
+ // Rename succeed
+ if ( ( oldSuffix.compare( newFileInfo.suffix(), Qt::CaseInsensitive ) != 0 )
+ && newFileInfo.isFile() ) {
+ // popup warning when the suffix of file is changed.
FmDlgUtils::information( hbTrId( "File may become unusable when file name extension is changed" ) );
}
}
--- a/filemanager/src/filemanager/src/fmfilebrowsewidget.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.h Fri Jul 23 11:12:24 2010 +0800
@@ -72,7 +72,6 @@
void setModelFilter( QDir::Filters filters );
int checkPathAndSetStyle( const QString& path );
- void refreshModel( const QString& path );
void sortFiles( TSortType sortType );
void activeSearchPanel();
@@ -80,6 +79,9 @@
bool cdUp();
void setRootPath( const QString &pathName );
+ // triggered when drive is ejected/inserted
+ void on_driveChanged();
+
void on_searchPanel_searchOptionsClicked();
void on_searchPanel_criteriaChanged( const QString &criteria );
void on_searchPanel_exitClicked();
@@ -143,7 +145,7 @@
bool mListLongPressed;
QModelIndex mActivatedModelIndex;
- // provide iocn from filemanger
+ // provide icon from filemanger
FmFileIconProvider *mFileIconProvider;
};
--- a/filemanager/src/filemanager/src/fmfileview.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfileview.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -39,7 +39,7 @@
FmFileView::FmFileView() : FmViewBase( EFileView ), mWidget( 0 ),
mUpButton( 0 ), mStyleAction( 0 ), mSelectableAction( 0 ),
- mFindAction( 0 ), mOperationService( 0 ), mMenu( 0 )
+ mFindAction( 0 ), mOperationService( 0 ), mMenu( 0 ), mIsFindDisabled( false )
{
mOperationService = FmViewManager::viewManager()->operationService();
initMenu();
@@ -93,8 +93,9 @@
void FmFileView::setFindDisabled( bool disable )
{
+ mIsFindDisabled = disable;
if( mFindAction ) {
- mFindAction->setDisabled( disable );
+ mFindAction->setDisabled( mIsFindDisabled );
}
}
@@ -212,6 +213,7 @@
mFindAction = new HbAction( this );
mFindAction->setObjectName( "leftAction" );
mFindAction->setText( hbTrId("txt_fmgr_opt_find") );
+ mFindAction->setDisabled( mIsFindDisabled );
toolBar()->addAction( mFindAction );
mToolBarRightAction = new HbAction( this );
@@ -415,7 +417,6 @@
if( !dir.mkdir( dirName ) ) {
FmDlgUtils::information( hbTrId("Operation failed!") );
}
- refreshModel( path );
break;
}
@@ -445,9 +446,9 @@
}
}
-void FmFileView::refreshModel( const QString &path )
+void FmFileView::on_driveChanged()
{
- mWidget->refreshModel( path );
+ mWidget->on_driveChanged();
}
void FmFileView::on_sortNameAction_triggered()
@@ -485,14 +486,14 @@
void FmFileView::on_mainWidget_setEmptyMenu( bool isMenuEmpty )
{
if( isMenuEmpty ){
- FmLogger::log( "setEmptyMenu true" );
+ FM_LOG( "setEmptyMenu true" );
if( !mMenu ) {
mMenu = takeMenu();
}
toolBar()->clearActions();
}
else {
- FmLogger::log( "setEmptyMenu false" );
+ FM_LOG( "setEmptyMenu false" );
if( mMenu ) {
setMenu( mMenu );
mMenu = 0;
--- a/filemanager/src/filemanager/src/fmfileview.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfileview.h Fri Jul 23 11:12:24 2010 +0800
@@ -42,7 +42,9 @@
public slots:
void setRootPath( const QString &pathName );
- void refreshModel( const QString &path );
+
+ // triggered when drive is ejected/inserted. connected by FmViewManager
+ void on_driveChanged();
signals:
// connected by viewmanager to close view
@@ -103,6 +105,9 @@
HbAction *mToolBarRightAction;
HbMenu *mMenu;
+
+ // store the disable state of find action. true for disabled
+ bool mIsFindDisabled;
};
#endif
--- a/filemanager/src/filemanager/src/fmfindresultmodel.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfindresultmodel.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -24,12 +24,24 @@
#include <hbglobal.h>
+/*!
+ \fn void finished()
+ This signal is emitted when find is finished.
+*/
+
+/*!
+ \fn void modelCountChanged( int count )
+ This signal is emitted when data count in model is changed
+ \a count is current data count in model.
+ Currently only start find and get more find result will emit this signal.
+*/
+
FmFindResultModel::FmFindResultModel( QObject *parent )
: QAbstractListModel( parent )
{
init();
connect( mFindThread, SIGNAL(finished()), this, SIGNAL(finished()) );
- connect( mFindThread, SIGNAL(found(int)), this, SLOT(on_findThread_found( int) ), Qt::BlockingQueuedConnection );
+ connect( mFindThread, SIGNAL(found(QStringList)), this, SLOT(on_findThread_found( QStringList) ), Qt::BlockingQueuedConnection );
}
FmFindResultModel::~FmFindResultModel()
@@ -37,17 +49,27 @@
delete mIconProvider;
}
+/*!
+ Returns the number of rows in the model. This value corresponds to the
+ number of items in the model's internal string list.
+
+ The optional \a parent argument is in most models used to specify
+ the parent of the rows to be counted. Because this is a list if a
+ valid parent is specified, the result will always be 0.
+
+ \sa insertRows(), removeRows(), QAbstractItemModel::rowCount()
+*/
int FmFindResultModel::rowCount( const QModelIndex &parent ) const
{
- if (!parent.isValid())
- return mFindResult.size();
+ if ( !parent.isValid() )
+ return mFindResult.count();
return 0;
}
int FmFindResultModel::columnCount( const QModelIndex &parent ) const
{
- if (!parent.isValid())
+ if ( !parent.isValid() )
return 4;
return 0;
@@ -106,24 +128,46 @@
return QAbstractItemModel::headerData( section, orientation, role );
}
-bool FmFindResultModel::insertRows( int row, int count, const QModelIndex &parent )
+/*!
+ Inserts \a dataList into the model, beginning at the given \a row.
+
+ The \a parent index of the rows is optional and is only used for
+ consistency with QAbstractItemModel. By default, a null index is
+ specified, indicating that the rows are inserted in the top level of
+ the model.
+
+ \sa QAbstractItemModel::insertRows()
+*/
+
+bool FmFindResultModel::insertRows( int row, const QStringList &dataList, const QModelIndex &parent )
{
- Q_UNUSED( parent );
- if (row < 0 || count < 1)
+ if ( row < 0 || dataList.count() < 1 || row > rowCount(parent) )
return false;
- beginInsertRows( QModelIndex(), row, row + count - 1 );
+ beginInsertRows( QModelIndex(), row, row + dataList.count() - 1 );
+ mFindResult.append( dataList );
+ endInsertRows();
- endInsertRows();
+ // emit modelCountChanged could let FmFindWidget switch style between EmptyTipWidget and ResultListview
+ // FmFindWidget will show an empty tip widget such as "No found files or folderss" if set 0 as parameter
+ emit modelCountChanged( rowCount() );
- return true;
+ return true;
}
+/*!
+ Removes \a count rows from the model, beginning at the given \a row.
+
+ The \a parent index of the rows is optional and is only used for
+ consistency with QAbstractItemModel. By default, a null index is
+ specified, indicating that the rows are removed in the top level of
+ the model.
+
+ \sa QAbstractItemModel::removeRows()
+*/
bool FmFindResultModel::removeRows( int row, int count, const QModelIndex &parent )
-{
- Q_UNUSED( parent );
-
- if (row < 0 || count < 1 || row + count > mFindResult.size())
+{
+ if (row < 0 || count < 1 || (row + count) > rowCount(parent) )
return false;
beginRemoveRows( QModelIndex(), row, row + count - 1 );
@@ -132,7 +176,11 @@
mFindResult.removeAt(row);
endRemoveRows();
-
+
+ // emit modelCountChanged could let FmFindWidget switch style between EmptyTipWidget and ResultListview
+ // FmFindWidget will show an empty tip widget such as "No found files or folderss" if set 0 as parameter
+ emit modelCountChanged( rowCount() );
+
return true;
}
@@ -166,13 +214,13 @@
void FmFindResultModel::find()
{
- if (mFindThread->isRunning())
+ if(mFindThread->isRunning())
return;
if( findPath().isEmpty() ){
mFindThread->setLastResult( mFindResult );
}
- removeRows( 0, mFindResult.size() );
+ removeRows( 0, rowCount() );
mFindThread->start();
}
@@ -187,13 +235,16 @@
return mFindThread->isRunning();
}
-void FmFindResultModel::on_findThread_found( int count )
+/*
+ Receive \a dataList as some found result
+ Then insert dataList to model
+*/
+void FmFindResultModel::on_findThread_found( const QStringList &dataList )
{
- if( count > 0 ) {
- int size = mFindResult.size();
- insertRows( mFindResult.size() - count, count );
+ if( dataList.isEmpty() ) {
+ return;
}
- emit modelCountChanged( mFindResult.size() );
+ insertRows( rowCount(), dataList );
}
bool FmFindResultModel::indexValid( const QModelIndex &index ) const
@@ -204,39 +255,43 @@
void FmFindResultModel::init()
{
- mFindThread = new FmFindThread( &mFindResult, this );
+ mFindThread = new FmFindThread( this );
mFindThread->setObjectName( "findThread" );
mIconProvider = new FmFileIconProvider();
}
-bool FmFindResultModel::caseNameLessThan(const QString &s1, const QString &s2)
+bool FmFindResultModel::caseNameLessThan(const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2)
{
- QFileInfo info1( s1 );
- QFileInfo info2( s2 );
+ QFileInfo info1( s1.first );
+ QFileInfo info2( s2.first );
return info1.fileName() < info2.fileName();
}
-bool FmFindResultModel::caseTimeLessThan(const QString &s1, const QString &s2)
+bool FmFindResultModel::caseTimeLessThan(const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2)
{
- QFileInfo info1( s1 );
- QFileInfo info2( s2 );
+ QFileInfo info1( s1.first );
+ QFileInfo info2( s2.first );
return info1.lastModified() < info2.lastModified();
}
-bool FmFindResultModel::caseSizeLessThan(const QString &s1, const QString &s2)
+bool FmFindResultModel::caseSizeLessThan(const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2)
{
- QFileInfo info1( s1 );
- QFileInfo info2( s2 );
+ QFileInfo info1( s1.first );
+ QFileInfo info2( s2.first );
return info1.size() < info2.size();
}
-bool FmFindResultModel::caseTypeLessThan(const QString &s1, const QString &s2)
+bool FmFindResultModel::caseTypeLessThan(const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2)
{
- QFileInfo info1( s1 );
- QFileInfo info2( s2 );
+ QFileInfo info1( s1.first );
+ QFileInfo info2( s2.first );
if( info1.isDir() != info2.isDir() ){
return info1.isDir();
@@ -246,33 +301,54 @@
}
}
-
+/*!
+ \reimp
+ Sort by \a column, which is aligned to \a SortFlag
+ \sa SortFlag
+*/
void FmFindResultModel::sort ( int column, Qt::SortOrder order )
{
+ // Sort algorithm comes from
+ // void QListModel::sort(int column, Qt::SortOrder order)
+
Q_UNUSED( order );
-
-// emit layoutAboutToBeChanged();
-
- QStringList lst( mFindResult );
- removeRows( 0, mFindResult.size() );
-
- switch( ( SortFlag )column )
+ emit layoutAboutToBeChanged();
+
+ // store value and row pair.
+ QVector < QPair<QString,int> > sorting(mFindResult.count());
+ for (int i = 0; i < mFindResult.count(); ++i) {
+ QString item = mFindResult.at(i);
+ sorting[i].first = item;
+ sorting[i].second = i;
+ }
+
+ // sort in "sorting"
+ switch( ( SortFlag )column )
{
case Name:
- qSort( lst.begin(), lst.end(), caseNameLessThan );
+ qSort( sorting.begin(), sorting.end(), caseNameLessThan );
break;
case Time:
- qSort( lst.begin(), lst.end(), caseTimeLessThan );
+ qSort( sorting.begin(), sorting.end(), caseTimeLessThan );
break;
case Size:
- qSort( lst.begin(), lst.end(), caseSizeLessThan );
+ qSort( sorting.begin(), sorting.end(), caseSizeLessThan );
break;
case Type:
- qSort( lst.begin(), lst.end(), caseTypeLessThan );
+ qSort( sorting.begin(), sorting.end(), caseTypeLessThan );
break;
- }
-
- mFindResult = lst;
- insertRows( 0, mFindResult.size() );
- emit modelCountChanged( mFindResult.size() );
+ }
+
+ // create from Indexes and toIndexes, then set sorted data back to mFindResult
+ QModelIndexList fromIndexes;
+ QModelIndexList toIndexes;
+ for (int r = 0; r < sorting.count(); ++r) {
+ QString item = sorting.at(r).first;
+ toIndexes.append(createIndex(r, 0));
+ fromIndexes.append(createIndex(sorting.at(r).second, 0));
+ mFindResult[r] = sorting.at(r).first;
+ }
+ changePersistentIndexList(fromIndexes, toIndexes);
+
+ emit layoutChanged();
}
--- a/filemanager/src/filemanager/src/fmfindresultmodel.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfindresultmodel.h Fri Jul 23 11:12:24 2010 +0800
@@ -21,6 +21,7 @@
#include "fmcommon.h"
+#include <QPair>
#include <QFileInfo>
#include <QStringList>
#include <QAbstractListModel>
@@ -50,7 +51,7 @@
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
- bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() );
+ bool insertRows( int row, const QStringList &dataList, const QModelIndex &parent = QModelIndex() );
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
QString filePath ( const QModelIndex & index ) const;
@@ -68,20 +69,21 @@
virtual void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder );
- static bool caseNameLessThan( const QString &s1, const QString &s2 );
- static bool caseTimeLessThan( const QString &s1, const QString &s2 );
- static bool caseSizeLessThan( const QString &s1, const QString &s2 );
- static bool caseTypeLessThan( const QString &s1, const QString &s2 );
+ static bool caseNameLessThan( const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2 );
+ static bool caseTimeLessThan( const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2 );
+ static bool caseSizeLessThan( const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2 );
+ static bool caseTypeLessThan( const QPair<QString,int> &s1,
+ const QPair<QString,int> &s2 );
signals:
void finished();
-
- // pass modelCountChanged signal to parent widget
- // so parent widget could change contentWiget between emptyTipsWidget and listWidget
void modelCountChanged( int count );
private slots:
- void on_findThread_found( int count );
+ void on_findThread_found( const QStringList &dataList );
private:
bool indexValid( const QModelIndex &index ) const;
--- a/filemanager/src/filemanager/src/fmfindthread.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfindthread.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -20,11 +20,28 @@
#include <QDir>
-FmFindThread::FmFindThread( QStringList *r, QObject *parent )
+// current path, it may come from findDirs.first().entryInfoList()
+#define CurrentDir QString( "." )
+
+// parent path, it may come from findDirs.first().entryInfoList()
+#define ParentDir QString( ".." )
+
+// if got 5 result and have not send notify event, then send notify event
+#define notifyPerCount 5
+
+// if got notifyPerElapsedTime milliseconds and have not send notify event, then send notify event.
+#define notifyPerElapsedTime 500
+
+/*!
+ \fn void found( const QStringList &dataList )
+ This signal is emitted when some data has been found and \a dataList is provided as data list.
+ Please connect this signal by Qt::BlockingQueuedConnection as dataList will be cleared immediately
+*/
+
+FmFindThread::FmFindThread( QObject *parent )
: QThread( parent )
{
setPriority( LowPriority );
- mResult = r;
}
FmFindThread::~FmFindThread()
@@ -59,6 +76,7 @@
void FmFindThread::run()
{
mStop = false;
+ tempResultList.clear();
if (findPattern.isEmpty() || !findPattern.isValid())
return;
@@ -73,7 +91,6 @@
QList<QDir> findDirs;
findDirs.append( dir );
- count = 0;
time.restart();
mStop = false;
while (!findDirs.isEmpty()) {
@@ -82,24 +99,26 @@
QString name = it->fileName();
QString absolutPath = it->absoluteFilePath();
if (findPattern.exactMatch( it->fileName() )) {
- mResult->append( it->absoluteFilePath() );
- ++count;
- if (count > 5)
+ tempResultList.append( it->absoluteFilePath() );
+ if (tempResultList.count() > notifyPerCount) {
emitFound();
- if (time.elapsed() > 500 && count > 0)
+ } else if (time.elapsed() > notifyPerElapsedTime && tempResultList.count() > 0) {
emitFound();
+ }
}
//We are stopped;
if (mStop) {
- if( count > 0 ) {
+ if( tempResultList.count() > 0 ) {
emitFound();
}
return;
}
-
- if (it->isDir() && it->fileName() != ".." && it->fileName() != "." )
+
+ // exclude directory named ".." and "."
+ if (it->isDir() && it->fileName() != ParentDir && it->fileName() != CurrentDir ) {
findDirs.append( QDir( it->absoluteFilePath() ) );
+ }
}
findDirs.removeFirst();
@@ -108,11 +127,16 @@
emitFound();
}
+/*
+ Emit signal "found" to send out found data
+*/
void FmFindThread::emitFound()
{
- emit found( count );
- count = 0;
- time.restart();
+ if( tempResultList.count() > 0 ) {
+ emit found( tempResultList );
+ tempResultList.clear();
+ time.restart();
+ }
}
void FmFindThread::setLastResult( QStringList r )
@@ -120,10 +144,13 @@
mLastResult = r;
}
+/*
+ Find keyword in last result
+ \sa setLastResult, this function must be called to set last result for findInResult
+*/
void FmFindThread::findInResult()
{
if( mFindPath.isEmpty() ){
- int count = mResult->count();
for (QStringList::Iterator it = mLastResult.begin(); it != mLastResult.end(); ++it) {
if (mStop){
return;
@@ -133,12 +160,12 @@
QString fileName = fileInfo.fileName();
if (findPattern.exactMatch( fileName ) ) {
- mResult->append( absolutPath );
- ++count;
- if (count > 5)
+ tempResultList.append( absolutPath );
+ if ( tempResultList.count() > notifyPerCount ) {
emitFound();
- if (time.elapsed() > 500 && count > 0)
- emitFound();
+ } else if (time.elapsed() > notifyPerElapsedTime && tempResultList.count() > 0) {
+ emitFound();
+ }
}
}
}
--- a/filemanager/src/filemanager/src/fmfindthread.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfindthread.h Fri Jul 23 11:12:24 2010 +0800
@@ -30,7 +30,7 @@
{
Q_OBJECT
public:
- explicit FmFindThread( QStringList *r, QObject *parent = 0 );
+ explicit FmFindThread( QObject *parent = 0 );
~FmFindThread();
QString findPath() const;
@@ -44,7 +44,7 @@
void stop();
signals:
- void found( int );
+ void found( const QStringList &dataList );
protected:
void run();
@@ -58,8 +58,9 @@
QString mFindPath;
QTime time;
QRegExp findPattern;
- QStringList *mResult;
QStringList mLastResult;
+ // Used to store temp search result. if emit found, the result will be cleared.
+ QStringList tempResultList;
};
#endif
--- a/filemanager/src/filemanager/src/fmfindview.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmfindview.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -44,7 +44,7 @@
void FmFindView::activated( const QString& pathName )
{
- FmLogger::log( QString( "activate path from findview:" ) + pathName );
+ FM_LOG( QString( "activate path from findview:" ) + pathName );
FmViewManager::viewManager()->createFileView( pathName, true, true );
}
--- a/filemanager/src/filemanager/src/fmmainwindow.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmmainwindow.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -17,6 +17,7 @@
*/
#include "fmmainwindow.h"
+#include "fmcommon.h"
#include <hbaction.h>
@@ -44,13 +45,13 @@
void FmMainWindow::init()
{
- FmLogger::log("FmMainWindow::init start");
+ FM_LOG("FmMainWindow::init start");
mViewManager = FmViewManager::CreateViewManager( this );
mViewManager->createDriverView();
connect( this, SIGNAL( orientationChanged( Qt::Orientation ) ),
this, SLOT( onOrientationChanged( Qt::Orientation ) ) );
- FmLogger::log("FmMainWindow::init end");
+ FM_LOG("FmMainWindow::init end");
// if ( orientation() == Qt::Vertical ) {
// createDriverView();
// } else {
@@ -60,12 +61,12 @@
void FmMainWindow::delayedLoading()
{
- FmLogger::log("FmMainWindow::delayedLoading start");
+ FM_LOG("FmMainWindow::delayedLoading start");
if( mFirstViewLoaded ) {
return;
}
init();
mFirstViewLoaded = true;
- FmLogger::log("FmMainWindow::delayedLoading end");
+ FM_LOG("FmMainWindow::delayedLoading end");
}
--- a/filemanager/src/filemanager/src/fmviewmanager.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmviewmanager.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -76,9 +76,6 @@
mOperationService = new FmOperationService( this );
mOperationService->setObjectName( "operationService" );
- mFsWatcher = new QFileSystemWatcher( this );
- mFsWatcher->setObjectName( "fsWatcher" );
-
mDriveWatcher = new FmDriveWatcher( this );
mDriveWatcher->setObjectName( "driveWatcher" );
mDriveWatcher->startWatch();
@@ -98,8 +95,6 @@
delete mOperationService;
mOperationService = 0;
- delete mFsWatcher;
- mFsWatcher = 0;
mDriveWatcher->cancelWatch();
delete mDriveWatcher;
@@ -145,10 +140,11 @@
}
}
-void FmViewManager::on_operationService_refreshModel( FmOperationBase *operationBase, const QString &path )
+void FmViewManager::on_operationService_driveSpaceChanged( FmOperationBase *operationBase )
{
Q_UNUSED( operationBase );
- emit refreshModel( path );
+ // request drive view to refresh
+ emit driveSpaceChanged();
}
void FmViewManager::on_operationService_notifyFinish( FmOperationBase *operationBase )
@@ -180,8 +176,11 @@
mMainWindow->addView( driverView );
mMainWindow->setCurrentView( driverView );
- connect( this, SIGNAL( refreshModel( QString ) ),
- driverView, SLOT( refreshModel( QString ) ) );
+ connect( this, SIGNAL( driveSpaceChanged() ),
+ driverView, SLOT( refreshDrive() ) );
+
+ connect( this, SIGNAL( driveChanged() ),
+ driverView, SLOT( refreshDrive() ) );
}
void FmViewManager::createFileView( const QString &path,
@@ -213,8 +212,8 @@
mMainWindow->addView( fileView );
mMainWindow->setCurrentView( fileView );
- connect( this, SIGNAL( refreshModel( const QString& ) ), //emit when need refresh models
- fileView, SLOT( refreshModel( const QString& ) ) );
+ connect( this, SIGNAL( driveChanged() ), //emit when drive changed.
+ fileView, SLOT( on_driveChanged() ) );
connect( fileView, SIGNAL( popViewAndShow() ), //emit when fileView need delete itself and pop&show view from stack.
this, SLOT( popViewAndShow() ), Qt::QueuedConnection );
@@ -244,8 +243,8 @@
mMainWindow->addView( backupView );
mMainWindow->setCurrentView( backupView );
- connect( this, SIGNAL( refreshModel( QString ) ), //emit when need refresh models
- backupView, SLOT( refreshModel( QString ) ) );
+ connect( this, SIGNAL( driveChanged() ), //emit when need refresh model
+ backupView, SLOT( refreshModel() ) );
connect( this, SIGNAL( refreshBackupDate() ), //emit when need refresh backup date
backupView, SLOT( refreshBackupDate() ) );
}
@@ -256,7 +255,7 @@
mMainWindow->addView( restoreView );
mMainWindow->setCurrentView( restoreView );
- connect( this, SIGNAL( refreshRestoreView() ), restoreView, SLOT( refreshRestoreView() ) );
+ connect( this, SIGNAL( driveChanged() ), restoreView, SLOT( refreshRestoreView() ) );
}
@@ -266,7 +265,7 @@
mMainWindow->addView( deleteBackupView );
mMainWindow->setCurrentView( deleteBackupView );
- connect( this, SIGNAL( refreshDeleteBackupView() ), deleteBackupView, SLOT( refreshDeleteBackupView() ) );
+ connect( this, SIGNAL( driveChanged() ), deleteBackupView, SLOT( refreshDeleteBackupView() ) );
}
@@ -274,35 +273,12 @@
return mMainWindow->orientation();
}
-void FmViewManager::on_fsWatcher_fileChanged(const QString &path)
-{
- emit refreshModel( path );
-}
-void FmViewManager::on_fsWatcher_directoryChanged(const QString &path)
-{
- emit refreshModel( path );
-}
-void FmViewManager::addWatchPath( const QString &path )
-{
- mFsWatcher->addPath( path );
-}
-void FmViewManager::removeWatchPath( const QString &path )
-{
- if( !mViewManager || !mFsWatcher ) {
- return;
- }
- mFsWatcher->removePath( path );
-}
-
-
void FmViewManager::on_driveWatcher_driveAddedOrChanged()
{
- FmLogger::log( QString( "FmViewManager::on_driveWatcher_driveAddedOrChanged start" ) );
- emit refreshModel( QString("") );
- emit refreshDeleteBackupView();
- emit refreshRestoreView();
+ FM_LOG( QString( "FmViewManager::on_driveWatcher_driveAddedOrChanged start" ) );
+ emit driveChanged();
checkDlgCloseUnit();
- FmLogger::log( QString( "FmViewManager::on_driveWatcher_driveAddedOrChanged end" ) );
+ FM_LOG( QString( "FmViewManager::on_driveWatcher_driveAddedOrChanged end" ) );
}
@@ -314,9 +290,9 @@
for( int i = 0; i < drives.length(); i++ ) {
QString drive( drives[i] + QString( ":/" ) );
if( !FmUtils::isDriveAvailable( drive ) ) {
- FmLogger::log( " close Dialog start " );
+ FM_LOG( " close Dialog start " );
unit->dialog()->close();
- FmLogger::log( " close Dialog end " );
+ FM_LOG( " close Dialog end " );
}
}
}
--- a/filemanager/src/filemanager/src/fmviewmanager.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/fmviewmanager.h Fri Jul 23 11:12:24 2010 +0800
@@ -32,6 +32,12 @@
class FmDriveWatcher;
class FmDialog;
+/*
+ * this class is used to record relationship between dialog and drive name
+ * FmViewManager will auto-close dialog which releated drive is not available again.
+ * for example. set name to MMC will pop a dialog, if add the dialog to FmViewManager::addDlgCloseUnit
+ * then after eject MMC, the dialog will be auto-closed by FmViewManager::checkDlgCloseUnit()
+ */
class FmDlgCloseUnit
{
public:
@@ -70,18 +76,17 @@
void createRestoreView();
void createDeleteBackupView();
- void addWatchPath( const QString &path );
- void removeWatchPath( const QString &path );
-
- // dialog close utils:
+ // add a close unit. this is used to auto-close dialog which releated drive is not available again.
void addDlgCloseUnit( FmDlgCloseUnit* unit )
{
- FmLogger::log( "FmViewManager::addDlgCloseUnit_" + unit->associatedDrives() );
+ FM_LOG( "FmViewManager::addDlgCloseUnit_" + unit->associatedDrives() );
mDlgCloseUnitList.append( unit );
}
+
+ // remove a close unit.
void removeDlgCloseUnit( FmDlgCloseUnit* unit )
{
- FmLogger::log( "FmViewManager::removeDlgCloseUnit_" + unit->associatedDrives() );
+ FM_LOG( "FmViewManager::removeDlgCloseUnit_" + unit->associatedDrives() );
mDlgCloseUnitList.removeOne( unit );
}
@@ -92,34 +97,49 @@
public slots:
/// popViewAndShow will delete current view and pop view from stack, then show it.
void popViewAndShow();
- void on_operationService_refreshModel( FmOperationBase* operationBase, const QString &path );
- void on_fsWatcher_fileChanged(const QString &path);
- void on_fsWatcher_directoryChanged(const QString &path);
+
+ // triggered when drive space is changed
+ // this slots is used to watch filemanager internal events
+ // drive space event from other applictaion will not be observed here
+ void on_operationService_driveSpaceChanged( FmOperationBase* operationBase );
+
+ // triggered when drive is ejected/inserted, or other drive event. it will impact available property
void on_driveWatcher_driveAddedOrChanged();
+
+ // if operation finished, some addition works( such as refresh... ) should be done in some views
+ // so this is the central controller function
void on_operationService_notifyFinish( FmOperationBase *operationBase );
+
signals:
- void refreshModel( const QString &path );
+ // emit when drive space is changed by some operation inside filemanager.
+ void driveSpaceChanged();
+
+ // emit when drive is ejected/inserted, this is watched by FmDriveWatcher
+ void driveChanged();
+
+ // when backup is created, backup date should be updated.
void refreshBackupDate();
- void refreshDeleteBackupView();
- void refreshRestoreView();
private:
- /// create view will push current view to stack
- // HbView *createView( FmViewType viewType );
-
- // void adjustSecondarySoftKey();
-
+ // when drive is ejected, this function will be called and exam dialogs in mDlgCloseUnitList
+ // it will colse dialogs if related drive is not available
void checkDlgCloseUnit();
private:
static FmViewManager *mViewManager;
private:
- FmMainWindow *mMainWindow;
+ // main window
+ FmMainWindow *mMainWindow;
+
+ // operation service, used to start operations such as copy, move, delete, format...
FmOperationService *mOperationService;
- QFileSystemWatcher *mFsWatcher;
- FmDriveWatcher *mDriveWatcher;
+
+ // used to watch drive event, for example, eject/insert drive
+ FmDriveWatcher *mDriveWatcher;
+ // used to record some dialogs that related to drive
+ // the dialog should be closed in checkDlgCloseUnit if drive is not available
QList<FmDlgCloseUnit*> mDlgCloseUnitList;
};
--- a/filemanager/src/filemanager/src/main.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/main.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -29,7 +29,7 @@
int main( int argc, char *argv[] )
{
- FmLogger::log( "main start" );
+ FM_LOG( "main start" );
HbApplication app( argc, argv );
QTranslator translator;
@@ -40,11 +40,11 @@
app.setApplicationName( hbTrId("txt_fmgr_title_file_manager") );
- FmLogger::log( "main_createMainwindow start" );
+ FM_LOG( "main_createMainwindow start" );
FmMainWindow mw;
- FmLogger::log( "main_createMainwindow end" );
+ FM_LOG( "main_createMainwindow end" );
mw.show();
- FmLogger::log( "main end" );
+ FM_LOG( "main end" );
return app.exec();
}
--- a/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -42,7 +42,7 @@
int FmOperationFormat::start()
{
QString logString = "FmOperationFormat::start";
- FmLogger::log( logString );
+ FM_LOG( logString );
emit notifyPreparing( false );
@@ -73,19 +73,19 @@
if( err == KErrNone ){
logString = "emit notifyStart";
- FmLogger::log( logString );
+ FM_LOG( logString );
mTotalSteps = finalValue;
emit notifyStart( false, finalValue );
}
logString = "Format open error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
if( err == KErrLocked ){
err = fs.ErasePassword( drive );
logString = "ErasePassword error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
if( err == KErrNone ){
err = format.Open(
@@ -93,12 +93,12 @@
if( err == KErrNone ){
logString = "emit notifyStart";
- FmLogger::log( logString );
+ FM_LOG( logString );
mTotalSteps = finalValue;
emit notifyStart( false, finalValue );
}
logString = "Second format open error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
}
}
@@ -110,13 +110,13 @@
if( err == KErrNone ){
logString = "emit notifyStart";
- FmLogger::log( logString );
+ FM_LOG( logString );
mTotalSteps = finalValue;
emit notifyStart( false, finalValue );
}
logString = "Reallyformat open error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
}
}
@@ -126,7 +126,7 @@
err = fs.FileSystemName( fsName, drive );
logString = "FileSystemName error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
if ( err == KErrNone && fsName.Length() > 0 )
{
@@ -137,7 +137,7 @@
ECoreAppUIsEjectCommandUsed );
logString = "Prevent SysAp shutting down applications" ;
- FmLogger::log( logString );
+ FM_LOG( logString );
}
else
{
@@ -146,7 +146,7 @@
err = KErrCancel;
logString = QString( "Format cancel" );
- FmLogger::log( logString );
+ FM_LOG( logString );
}
}
@@ -154,17 +154,17 @@
while ( finalValue ){
logString = "Format tracks:" + QString::number( finalValue );
- FmLogger::log( logString );
+ FM_LOG( logString );
err = format.Next( finalValue );
if( err != KErrNone ){
logString = "Format error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
break;
}
logString = "emit notifyProgress";
- FmLogger::log( logString );
+ FM_LOG( logString );
emit notifyProgress( mTotalSteps - finalValue );
}
}
--- a/filemanager/src/filemanager/src/operationservice/fmoperationformat_win.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat_win.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -38,7 +38,7 @@
int FmOperationFormat::start()
{
QString logString = "FmOperationFormat::start";
- FmLogger::log( logString );
+ FM_LOG( logString );
if( mDriverName.isEmpty() ) {
return FmErrWrongParam;
--- a/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -45,7 +45,7 @@
QString questionText = QString( "file " ) +
srcFile + QString( " already exist, please rename:" );
QString value;
- QFileInfo fileInfo(srcFile);
+ QFileInfo srcFileInfo(srcFile);
QStringList regExpList = (QStringList() << Regex_ValidFileFolderName << Regex_ValidNotEndWithDot );
bool ret = FmDlgUtils::showTextQuery( questionText, value, regExpList,
@@ -54,7 +54,7 @@
// remove whitespace from the start and the end.
value = value.trimmed();
QString newTargetPath = FmUtils::fillPathWithSplash(
- fileInfo.absolutePath() ) + value;
+ srcFileInfo.absolutePath() ) + value;
QString errString;
// check if name/path is available for use.
if( !FmUtils::checkNewFolderOrFile( value, newTargetPath, errString ) ) {
@@ -66,7 +66,14 @@
}
}
if( ret ) {
+ // Got file/folder name for rename, save it to destFile
*destFile = value;
+ QFileInfo destFileInfo( *destFile );
+ if ( ( srcFileInfo.suffix().compare( destFileInfo.suffix(), Qt::CaseInsensitive ) != 0 )
+ && srcFileInfo.isFile() ) {
+ // popup warning when the suffix of file is changed.
+ FmDlgUtils::information( hbTrId( "File may become unusable when file name extension is changed" ) );
+ }
}
}
@@ -87,6 +94,7 @@
void FmOperationResultProcesser::onShowNote( FmOperationBase* operationBase, const char *noteString )
{
+ Q_UNUSED( operationBase );
FmDlgUtils::information(hbTrId(noteString));
}
@@ -224,7 +232,7 @@
int err = FmUtils::renameDrive( driveName, volumeName );
if ( err == FmErrNone ) {
FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
- mOperationService->on_operationThread_refreshModel( driveName );
+ mOperationService->on_operationThread_driveSpaceChanged();
break;
} else if( err == FmErrBadName ) {
FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) );
--- a/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -288,9 +288,9 @@
mCurrentOperation, srcFile, destFile, isAccepted );
}
-void FmOperationService::on_operationThread_refreshModel( const QString &path )
+void FmOperationService::on_operationThread_driveSpaceChanged()
{
- emit refreshModel( mCurrentOperation, path );
+ emit driveSpaceChanged( mCurrentOperation );
}
void FmOperationService::on_operationThread_showNote( const char *noteString )
{
--- a/filemanager/src/filemanager/src/operationservice/fmoperationservice.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationservice.h Fri Jul 23 11:12:24 2010 +0800
@@ -94,7 +94,7 @@
void on_operationThread_askForRename( const QString &srcFile, QString *destFile );
void on_operationThread_askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
- void on_operationThread_refreshModel( const QString &path );
+ void on_operationThread_driveSpaceChanged();
void on_operationThread_showNote( const char *noteString );
void on_operationThread_notifyWaiting( bool cancelable );
void on_operationThread_notifyPreparing( bool cancelable );
@@ -106,7 +106,7 @@
signals:
// void askForRename( FmOperationBase* operationBase, const QString &srcFile, QString &destFile );
- void refreshModel( FmOperationBase* operationBase, const QString& filePath );
+ void driveSpaceChanged( FmOperationBase* operationBase );
void notifyWaiting( FmOperationBase* operationBase, bool cancelable );
void notifyPreparing( FmOperationBase* operationBase, bool cancelable ); // this step could not be used if not needed.
--- a/filemanager/src/filemanager/src/operationservice/fmoperationthread.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationthread.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -177,7 +177,6 @@
{
mErrString.clear();
FmOperationCopy *operationCopy = static_cast<FmOperationCopy*>(mOperationBase);
- QString refreshDestPath = QFileInfo( operationCopy->targetPath() ).dir().absolutePath();
int ret = operationCopy->start( &mStop, &mErrString );
switch( ret )
@@ -187,14 +186,15 @@
break;
case FmErrNone:
emit notifyFinish();
- emit refreshModel( refreshDestPath );
break;
default:
emit notifyError( ret, mErrString );
break;
}
- // refresh driveview no care if cancel, error or finished.
- emit refreshModel( QString("") );
+ // refresh drive space no care if cancel, error or finished.
+ // as filemanger cannot notify drive space changed
+ // do not refresh path as QFileSystemModel will do auto-refresh
+ emit driveSpaceChanged();
break;
}
case FmOperationService::EOperationTypeMove:
@@ -202,8 +202,6 @@
mErrString.clear();
FmOperationMove *operationMove = static_cast<FmOperationMove*>(mOperationBase);
- QString refreshSrcPath = QFileInfo( operationMove->sourceList().front() ).dir().absolutePath();
-
int ret = operationMove->start( &mStop, &mErrString );
switch( ret )
{
@@ -212,14 +210,14 @@
break;
case FmErrNone:
emit notifyFinish();
- emit refreshModel( refreshSrcPath );
- emit refreshModel( operationMove->targetPath() );
break;
default:
emit notifyError( ret, mErrString );
}
- // refresh driveview no care if cancel, error or finished.
- emit refreshModel( QString("") );
+ // refresh drive space no care if cancel, error or finished.
+ // as filemanger cannot notify drive space changed
+ // do not refresh path as QFileSystemModel will do auto-refresh
+ emit driveSpaceChanged();
break;
}
case FmOperationService::EOperationTypeRemove:
@@ -227,8 +225,6 @@
mErrString.clear();
FmOperationRemove *operationRemove = static_cast<FmOperationRemove*>(mOperationBase);
- QString refreshSrcPath = QFileInfo( operationRemove->pathList().front() ).dir().absolutePath();
-
int ret = operationRemove->start( &mStop, &mErrString );
switch( ret )
{
@@ -241,27 +237,30 @@
default:
emit notifyError( ret, mErrString );
}
- // refresh driveview no care if cancel, error or finished.
- emit refreshModel( QString("") );
+ // refresh drive space no care if cancel, error or finished.
+ // as filemanger cannot notify drive space changed
+ // do not refresh path as QFileSystemModel will do auto-refresh
+ emit driveSpaceChanged();
break;
}
case FmOperationService::EOperationTypeFormat:
{
// emit notifyWaiting( false );
- FmLogger::log(QString("start format"));
+ FM_LOG(QString("start format"));
FmOperationFormat *operationFormat = static_cast<FmOperationFormat*>( mOperationBase );
- FmLogger::log(QString("get param and start format"));
+ FM_LOG(QString("get param and start format"));
- QString refreshSrcPath = operationFormat->driverName();
-// if ( FmErrNone != FmUtils::formatDrive( operationFormat->driverName() ) ) {
if ( FmErrNone != operationFormat->start() ) {
emit notifyError( FmErrTypeFormatFailed, operationFormat->driverName() );
return;
}
- FmLogger::log(QString("format done"));
+ FM_LOG(QString("format done"));
emit notifyFinish();
- emit refreshModel( refreshSrcPath );
- FmLogger::log(QString("format done and emit finish"));
+ // refresh drive space no care if cancel, error or finished.
+ // as filemanger cannot notify drive space changed
+ // do not refresh path as QFileSystemModel will do auto-refresh
+ emit driveSpaceChanged();
+ FM_LOG(QString("format done and emit finish"));
break;
}
case FmOperationService::EOperationTypeDriveDetails:
--- a/filemanager/src/filemanager/src/operationservice/fmoperationthread.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationthread.h Fri Jul 23 11:12:24 2010 +0800
@@ -53,7 +53,7 @@
signals:
void askForRename( const QString &srcFile, QString *destFile );
void askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
- void refreshModel( const QString &path );
+ void driveSpaceChanged();
void showNote(const char*);
void notifyWaiting( bool cancelable );
--- a/filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -98,28 +98,28 @@
QList<FmBkupBackupCategory*> backupCategoryList,
QString drive, quint32 content)
{
- FmLogger::log( "FmBkupEnginePrivate::startBackup_with drive: " + drive +
+ FM_LOG( "FmBkupEnginePrivate::startBackup_with drive: " + drive +
"_number:" + QString::number(DriverNameToNumber( drive )));
if( drive.isEmpty() ) {
iError = KErrPathNotFound;
- FmLogger::log( "FmBkupEnginePrivate::startBackup_with return with KErrPathNotFound because drive is empty" );
+ FM_LOG( "FmBkupEnginePrivate::startBackup_with return with KErrPathNotFound because drive is empty" );
return false;
}
QStringList backupableDriveList;
getBackupDriveList( backupableDriveList );
if( !backupableDriveList.contains( drive, Qt::CaseInsensitive ) ) {
iError = KErrPathNotFound;
- FmLogger::log( "FmBkupEnginePrivate::startBackup_with return with KErrPathNotFound because drive is not available" );
+ FM_LOG( "FmBkupEnginePrivate::startBackup_with return with KErrPathNotFound because drive is not available" );
return false;
}
QString logString;
logString = "startBackup";
- FmLogger::log( logString );
+ FM_LOG( logString );
iDrvAndOpList->Reset();
iBkupCategoryList->ResetAndDestroy();
logString = "startBackup_driveroperation count:" + QString::number(drivesAndOperationList.count());
- FmLogger::log( logString );
+ FM_LOG( logString );
for( QList<FmBkupDrivesAndOperation* >::iterator it = drivesAndOperationList.begin();
it != drivesAndOperationList.end(); ++it ) {
@@ -131,7 +131,7 @@
}
logString = "startBackup_backupCategoryList count:" + QString::number(backupCategoryList.count());
- FmLogger::log( logString );
+ FM_LOG( logString );
for( QList<FmBkupBackupCategory* >::iterator it = backupCategoryList.begin();
@@ -170,7 +170,7 @@
//TUint32 bkupContent = 63;
logString = "startBackup_new param";
- FmLogger::log( logString );
+ FM_LOG( logString );
CMMCScBkupOpParamsBackupFull* params =
CMMCScBkupOpParamsBackupFull::NewL(
@@ -183,14 +183,14 @@
logString = "startBackup_param ok";
- FmLogger::log( logString );
+ FM_LOG( logString );
CCoeEnv* coeEnv = CCoeEnv::Static();
CEikonEnv* eikonEnv = (STATIC_CAST(CEikonEnv*,coeEnv));
eikonEnv->SetSystem(ETrue);
logString = "startBackup_StartOperationL";
- FmLogger::log( logString );
+ FM_LOG( logString );
QList< FmRestoreInfo > restoreInfoList;
GetRestoreInfoArray( drivesAndOperationList, restoreInfoList, drive );
@@ -220,14 +220,14 @@
EMMCScBkupOperationTypeFullBackup, *this, params ) );
logString = "startBackup_end with error:" + QString::number(err) ;
- FmLogger::log( logString );
+ FM_LOG( logString );
return (err == KErrNone);
}
void FmBkupEnginePrivate::cancelBackup()
{
QString logString = "cancelBackup";
- FmLogger::log(logString);
+ FM_LOG(logString);
switch( mProcess )
{
case FmBkupEngine::ProcessBackup: // FALLTHROUGH
@@ -408,13 +408,13 @@
break;
}
}
- FmLogger::log( logString );
+ FM_LOG( logString );
return ret;
}
int FmBkupEnginePrivate::error()
{
- FmLogger::log( "FmBkupEnginePrivate::error:" + QString::number( iError ) );
+ FM_LOG( "FmBkupEnginePrivate::error:" + QString::number( iError ) );
switch (iError)
{
case KErrNone:
--- a/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -68,23 +68,23 @@
void FmFileWidget::setRootPath( const QString &pathName )
{
- FmLogger::log( "FmFileWidget::setRootPath start" );
+ FM_LOG( "FmFileWidget::setRootPath start" );
// If path is empty or can not access, set model as DriveModel
// Otherwise set model as FileSystemModel, means it will return to drive view if error occur.
if( ( pathName.isEmpty() ) || ( FmErrNone != FmUtils::isPathAccessabel( pathName ) ) ) {
- FmLogger::log( "FmFileWidget::setRootPath set drive model" );
+ FM_LOG( "FmFileWidget::setRootPath set drive model" );
setModel( mDriveModel );
- FmLogger::log( "FmFileWidget::setRootPath set drive model end" );
+ FM_LOG( "FmFileWidget::setRootPath set drive model end" );
emit pathChanged( QString() );
} else {
- FmLogger::log( "FmFileWidget::setRootPath set dir model end" );
+ FM_LOG( "FmFileWidget::setRootPath set dir model end" );
setModel( mFileSystemModel );
- FmLogger::log( "FmFileWidget::setRootPath set dir model end" );
+ FM_LOG( "FmFileWidget::setRootPath set dir model end" );
mListView->setRootIndex( mFileSystemModel->setRootPath( pathName ) );
- FmLogger::log( "FmFileWidget::setRootPath set rootIndex" );
+ FM_LOG( "FmFileWidget::setRootPath set rootIndex" );
emit pathChanged( pathName );
}
- FmLogger::log( "FmFileWidget::setRootPath end" );
+ FM_LOG( "FmFileWidget::setRootPath end" );
}
void FmFileWidget::on_list_activated( const QModelIndex &index )
{
@@ -94,41 +94,41 @@
void FmFileWidget::on_listActivated()
{
- FmLogger::log("FmFileWidget::on_list_activated start" );
+ FM_LOG("FmFileWidget::on_list_activated start" );
if( mCurrentModel == mDriveModel ) {
//If currenty model is DriveModel, open drive and set path
QString driveName = mDriveModel->driveName( mActivatedModelIndex );
QString checkedPath = FmUtils::checkDriveToFolderFilter( driveName );
if( checkedPath.isEmpty() ) {
- FmLogger::log("FmFileWidget::on_list_activated end becaise checkedpath empty" );
+ FM_LOG("FmFileWidget::on_list_activated end becaise checkedpath empty" );
return;
}
- FmLogger::log("FmFileWidget::on_list_activated setModel dir start" );
+ FM_LOG("FmFileWidget::on_list_activated setModel dir start" );
setModel( mFileSystemModel );
- FmLogger::log("FmFileWidget::on_list_activated setModel dir end" );
+ FM_LOG("FmFileWidget::on_list_activated setModel dir end" );
setRootPath( checkedPath );
- FmLogger::log("FmFileWidget::on_list_activated setRootIndex" );
+ FM_LOG("FmFileWidget::on_list_activated setRootIndex" );
emit pathChanged( checkedPath );
- FmLogger::log("FmFileWidget::on_list_activated finish emit pathChanged" );
+ FM_LOG("FmFileWidget::on_list_activated finish emit pathChanged" );
}
else if( mCurrentModel == mFileSystemModel ) {
//If currenty model is FileSystemModel, open path or emit file activate signal.
if ( mFileSystemModel->isDir( mActivatedModelIndex ) ) {
- FmLogger::log("FmFileWidget::on_list_activated start changeRootIndex" );
+ FM_LOG("FmFileWidget::on_list_activated start changeRootIndex" );
changeRootIndex( mActivatedModelIndex );
- FmLogger::log("FmFileWidget::on_list_activated finish changeRootIndex" );
+ FM_LOG("FmFileWidget::on_list_activated finish changeRootIndex" );
} else {
QFileInfo fileInfo( mFileSystemModel->filePath( mActivatedModelIndex ) );
if( fileInfo.isFile() ) {
emit fileActivated( fileInfo.fileName() );
- FmLogger::log("FmFileWidget::on_list_activated finish emit fileActivated" );
+ FM_LOG("FmFileWidget::on_list_activated finish emit fileActivated" );
}
}
} else {
Q_ASSERT( false );
}
- FmLogger::log("FmFileWidget::on_list_activated end" );
+ FM_LOG("FmFileWidget::on_list_activated end" );
}
void FmFileWidget::setModelFilter( QDir::Filters filters )
@@ -143,9 +143,9 @@
void FmFileWidget::changeRootIndex( const QModelIndex &index )
{
- FmLogger::log("FmFileWidget::changeRootIndex start" );
+ FM_LOG("FmFileWidget::changeRootIndex start" );
if( mCurrentModel != mFileSystemModel ) {
- FmLogger::log("FmFileWidget::changeRootIndex end because model not equal mFileSystemModel" );
+ FM_LOG("FmFileWidget::changeRootIndex end because model not equal mFileSystemModel" );
return;
}
@@ -153,7 +153,7 @@
QString filePath = mFileSystemModel->fileInfo( index ).absoluteFilePath();
// pathChanged signal will be emitted in setRootPath
setRootPath( filePath );
- FmLogger::log("FmFileWidget::changeRootIndex end" );
+ FM_LOG("FmFileWidget::changeRootIndex end" );
}
void FmFileWidget::init()
@@ -232,7 +232,7 @@
void FmFileWidget::on_driveWatcher_driveAddedOrChanged()
{
- FmLogger::log( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged start" ) );
+ FM_LOG( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged start" ) );
mDriveModel->refresh();
if( currentViewType() == DriveView ) {
setModel( 0 );
@@ -241,11 +241,11 @@
} else if( currentViewType() == DirView ) {
if( FmErrNone != FmUtils::isPathAccessabel( currentPath().absoluteFilePath() ) ) {
// path not available, set model to drive
- FmLogger::log( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged path not availeable, set drivemodel:"
+ FM_LOG( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged path not availeable, set drivemodel:"
+ currentPath().absoluteFilePath() ) );
setModel( mDriveModel );
emit pathChanged( QString() );
}
}
- FmLogger::log( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged end" ) );
+ FM_LOG( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged end" ) );
}
--- a/filemanager/src/inc/fmdrivemodel.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmdrivemodel.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -48,10 +48,10 @@
mDriveListProvider->getDriveList( mDriveList );
} else {
if( mOptions & HideUnAvailableDrive ) {
- FmLogger::log( QString( "FmDriveModel::refresh HideUnAvailableDrive_true" ) );
+ FM_LOG( QString( "FmDriveModel::refresh HideUnAvailableDrive_true" ) );
FmUtils::getDriveList( mDriveList, true );
} else {
- FmLogger::log( QString( "FmDriveModel::refresh HideUnAvailableDrive_false" ) );
+ FM_LOG( QString( "FmDriveModel::refresh HideUnAvailableDrive_false" ) );
FmUtils::getDriveList( mDriveList, false );
}
}
--- a/filemanager/src/inc/fmdrivewatcher/private/symbian/fmdriveevent.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmdrivewatcher/private/symbian/fmdriveevent.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -112,7 +112,7 @@
//
void CFmDriveEvent::Setup()
{
- FmLogger::log( QString( "CFmDriveEvent::Setup start" ) );
+ FM_LOG( QString( "CFmDriveEvent::Setup start" ) );
if( IsActive() )
{
return;
@@ -120,7 +120,7 @@
iFs.NotifyChange( ENotifyDisk, iStatus );
SetActive();
- FmLogger::log( QString( "CFmDriveEvent::Setup end" ) );
+ FM_LOG( QString( "CFmDriveEvent::Setup end" ) );
}
// -----------------------------------------------------------------------------
--- a/filemanager/src/inc/fmdrivewatcher/private/symbian/fmdrivewatcherprivate.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmdrivewatcher/private/symbian/fmdrivewatcherprivate.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -47,7 +47,7 @@
void FmDriveWatcherPrivate::OnDriveAddedOrChangedL()
{
- FmLogger::log( QString( "FmDriveWatcherPrivate::OnDriveAddedOrChangedL start" ) );
+ FM_LOG( QString( "FmDriveWatcherPrivate::OnDriveAddedOrChangedL start" ) );
emit driveAddedOrChanged();
- FmLogger::log( QString( "FmDriveWatcherPrivate::OnDriveAddedOrChangedL end" ) );
+ FM_LOG( QString( "FmDriveWatcherPrivate::OnDriveAddedOrChangedL end" ) );
}
--- a/filemanager/src/inc/fmfiletyperecognizer.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmfiletyperecognizer.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -23,95 +23,69 @@
FmFileTypeRecognizer::FmFileTypeRecognizer()
{
- QStringList fileExtensionList;
-
- fileExtensionList.append( QString( "bmp" ) );
- fileExtensionList.append( QString( "gif" ) );
- fileExtensionList.append( QString( "jpe" ) );
- fileExtensionList.append( QString( "jpeg" ) );
- fileExtensionList.append( QString( "jpg" ) );
- fileExtensionList.append( QString( "ota" ) );
- fileExtensionList.append( QString( "png" ) );
- fileExtensionList.append( QString( "tif" ) );
- fileExtensionList.append( QString( "tiff" ) );
- fileExtensionList.append( QString( "wbmp" ) );
- fileExtensionList.append( QString( "wmf" ) );
- fileExtensionList.append( QString( "jp2" ) );
- fileExtensionList.append( QString( "jpg2" ) );
- fileExtensionList.append( QString( "jp3" ) );
- fileExtensionList.append( QString( "ico" ) );
- fileExtensionList.append( QString( "vcf" ) );
- mFileTypeMap.insert( FileTypeImage, fileExtensionList );
-
- fileExtensionList.clear();
- fileExtensionList.append( QString( "3gp" ) );
- fileExtensionList.append( QString( "mp4" ) );
- fileExtensionList.append( QString( "nim" ) );
- fileExtensionList.append( QString( "rm" ) );
- fileExtensionList.append( QString( "rv" ) );
- fileExtensionList.append( QString( "wmv" ) );
- fileExtensionList.append( QString( "3g2" ) );
- fileExtensionList.append( QString( "rmvb") );
- fileExtensionList.append( QString( "mkv" ) );
- mFileTypeMap.insert( FileTypeVideo, fileExtensionList );
+ mFileExtensionMap.insert( QString( "bmp" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "gif" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "jpe" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "jpeg" ),FileTypeImage );
+ mFileExtensionMap.insert( QString( "jpg" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "ota" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "png" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "tif" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "tiff" ),FileTypeImage );
+ mFileExtensionMap.insert( QString( "wbmp" ),FileTypeImage );
+ mFileExtensionMap.insert( QString( "wmf" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "jp2" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "jpg2" ),FileTypeImage );
+ mFileExtensionMap.insert( QString( "jp3" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "ico" ), FileTypeImage );
+ mFileExtensionMap.insert( QString( "vcf" ), FileTypeImage );
+
+ mFileExtensionMap.insert( QString( "3gp" ), FileTypeVideo );
+ mFileExtensionMap.insert( QString( "mp4" ), FileTypeVideo );
+ mFileExtensionMap.insert( QString( "nim" ), FileTypeVideo );
+ mFileExtensionMap.insert( QString( "rm" ), FileTypeVideo );
+ mFileExtensionMap.insert( QString( "rv" ), FileTypeVideo );
+ mFileExtensionMap.insert( QString( "wmv" ), FileTypeVideo );
+ mFileExtensionMap.insert( QString( "3g2" ), FileTypeVideo );
+ mFileExtensionMap.insert( QString( "rmvb" ),FileTypeVideo );
+ mFileExtensionMap.insert( QString( "mkv" ), FileTypeVideo );
- fileExtensionList.clear();
- fileExtensionList.append( QString( "aac" ) );
- fileExtensionList.append( QString( "amr" ) );
- fileExtensionList.append( QString( "au" ) );
- fileExtensionList.append( QString( "awb" ) );
- fileExtensionList.append( QString( "mid" ) );
- fileExtensionList.append( QString( "mp3" ) );
- fileExtensionList.append( QString( "ra" ) );
- fileExtensionList.append( QString( "rmf" ) );
- fileExtensionList.append( QString( "rng" ) );
- fileExtensionList.append( QString( "snd" ) );
- fileExtensionList.append( QString( "wav" ) );
- fileExtensionList.append( QString( "wve" ) );
- fileExtensionList.append( QString( "wma" ) );
- fileExtensionList.append( QString( "m4a" ) );
- fileExtensionList.append( QString( "ott" ) );
- fileExtensionList.append( QString( "mxmf" ) );
- mFileTypeMap.insert( FileTypeTone, fileExtensionList );
- fileExtensionList.clear();
- fileExtensionList.append( QString( "doc" ) );
- fileExtensionList.append( QString( "pdf" ) );
- fileExtensionList.append( QString( "pps" ) );
- fileExtensionList.append( QString( "ppt" ) );
- fileExtensionList.append( QString( "txt" ) );
- fileExtensionList.append( QString( "xls" ) );
- mFileTypeMap.insert( FileTypeText, fileExtensionList );
+ mFileExtensionMap.insert( QString( "aac" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "amr" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "au" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "awb" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "mid" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "mp3" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "ra" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "rmf" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "rng" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "snd" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "wav" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "wve" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "wma" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "m4a" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "ott" ), FileTypeTone );
+ mFileExtensionMap.insert( QString( "mxmf" ),FileTypeTone );
+
+ mFileExtensionMap.insert( QString( "doc" ), FileTypeText );
+ mFileExtensionMap.insert( QString( "pdf" ), FileTypeText );
+ mFileExtensionMap.insert( QString( "pps" ), FileTypeText );
+ mFileExtensionMap.insert( QString( "ppt" ), FileTypeText );
+ mFileExtensionMap.insert( QString( "txt" ), FileTypeText );
+ mFileExtensionMap.insert( QString( "xls" ), FileTypeText );
- fileExtensionList.clear();
- fileExtensionList.append( QString( "sis" ) );
- fileExtensionList.append( QString( "sisx" ) );
- mFileTypeMap.insert( FileTypeSisx, fileExtensionList );
+ mFileExtensionMap.insert( QString( "sis" ), FileTypeSisx );
+ mFileExtensionMap.insert( QString( "sisx" ),FileTypeSisx );
+
+ mFileExtensionMap.insert( QString( "jad" ), FileTypeJava );
+ mFileExtensionMap.insert( QString( "jar" ), FileTypeJava );
- fileExtensionList.clear();
- fileExtensionList.append( QString( "jad" ) );
- fileExtensionList.append( QString( "jar" ) );
- mFileTypeMap.insert( FileTypeJava, fileExtensionList );
-
- fileExtensionList.clear();
- fileExtensionList.append( QString( "swf" ) );
- mFileTypeMap.insert( FileTypeFlash, fileExtensionList );
+ mFileExtensionMap.insert( QString( "swf" ), FileTypeFlash );
// have not handle FileTypePlaylist
// have not handle FileTypeWidget
// have not handle FileTypeWebLink
-
- // make mFileExtensionMap( data map for extenstion ) from mFileTypeMap
- // this map is used to speed up recognize
- QMapIterator<FileType, QStringList> i( mFileTypeMap );
- while (i.hasNext()) {
- i.next();
- foreach( const QString extension, i.value() ) {
- mFileExtensionMap.insert( extension, i.key() );
- }
- }
-
-
}
FmFileTypeRecognizer::~FmFileTypeRecognizer()
@@ -133,8 +107,3 @@
//if can not find key, return default value: FileTypeUnKnown
return mFileExtensionMap.value( fileInfo.suffix().toLower(), FileTypeUnKnown );
}
-
-const QStringList FmFileTypeRecognizer::getFileListFromFileType( const FmFileTypeRecognizer::FileType fileType ) const
-{
- return mFileTypeMap.value( fileType, QStringList() );
-}
--- a/filemanager/src/inc/fmfiletyperecognizer.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmfiletyperecognizer.h Fri Jul 23 11:12:24 2010 +0800
@@ -19,6 +19,7 @@
#ifndef FMFILERECOGNIZER_H
#define FMFILERECOGNIZER_H
+#include "fmcommon.h"
#include <QString>
#include <QList>
#include <QStringList>
@@ -57,17 +58,8 @@
*/
FmFileTypeRecognizer::FileType getType( const QString& path ) const ;
- /*!
- Profide a list of extension name by designate the FileType.
- */
- const QStringList getFileListFromFileType( const FmFileTypeRecognizer::FileType fileType ) const;
-
private:
- // used to store FileType, extension name list pare.
- QMap<FileType, QStringList> mFileTypeMap;
-
// used to store single extension name, FileType pare.
- // this map comes from mFileTypeMap
QMap<QString, FileType> mFileExtensionMap;
};
--- a/filemanager/src/inc/fmlogger.h Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmlogger.h Fri Jul 23 11:12:24 2010 +0800
@@ -20,11 +20,17 @@
#define FMLOG_PATH QString( "C:\\data\\fileman.txt" )
-
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QDateTime>
+
+#ifdef _DEBUG_LOG_ENABLE_
+ #define FM_LOG(str) FmLogger::log( str );
+#else
+ #define FM_LOG(str)
+#endif
+
class FmLogger
{
public:
--- a/filemanager/src/inc/fmutils_s60.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmutils_s60.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -195,7 +195,7 @@
"_driveInfoErr:" + QString::number( driveInfoErr ) +
"_errorCode:" + QString::number( errorCode ) +
"_driveSatus:" + QString::number( state ) );
- FmLogger::log( logString );
+ FM_LOG( logString );
return FmDriverInfo( volumeInfo.iSize, volumeInfo.iFree, driverName, volumeName, state );
}
@@ -218,9 +218,9 @@
return FmErrWrongParam;
}
QString logString = "Drive name:" + driverName;
- FmLogger::log( logString );
+ FM_LOG( logString );
logString = "Password:" + Pwd;
- FmLogger::log( logString );
+ FM_LOG( logString );
CCoeEnv *env = CCoeEnv::Static();
RFs& fs = env->FsSession();
@@ -237,10 +237,10 @@
int err( fs.ClearPassword( drive, password ) );
logString = "Drive:" + QString::number( drive );
- FmLogger::log( logString );
+ FM_LOG( logString );
logString = "Clear password error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
if( err == KErrNone ){
return FmErrNone;
@@ -259,9 +259,9 @@
return FmErrWrongParam;
}
QString logString = "Drive name:" + driverName;
- FmLogger::log( logString );
+ FM_LOG( logString );
logString = "Password:" + Pwd;
- FmLogger::log( logString );
+ FM_LOG( logString );
CCoeEnv *env = CCoeEnv::Static();
RFs& fs = env->FsSession();
@@ -277,9 +277,9 @@
int err( fs.UnlockDrive( drive, password, ETrue) );
logString = "Drive:" + QString::number( drive );
- FmLogger::log( logString );
+ FM_LOG( logString );
logString = "Unlock drive error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
if( err == KErrNone ){
return FmErrNone;
@@ -305,7 +305,7 @@
}
QString logString = "checkDrivePwd Drive name:" + driverName;
logString += " password:" + pwd;
- FmLogger::log( logString );
+ FM_LOG( logString );
return setDrivePwd( driverName, pwd, pwd );
}
@@ -318,7 +318,7 @@
QString logString = "setDrivePwd Drive name:" + driverName ;
logString += " Old password:" + oldPwd;
logString += " New password:" + newPwd;
- FmLogger::log( logString );
+ FM_LOG( logString );
CCoeEnv *env = CCoeEnv::Static();
RFs& fs = env->FsSession();
@@ -341,9 +341,9 @@
int err( fs.LockDrive( drive, oldPassword, newPassword, ETrue ) );
logString = "Drive:" + QString::number( drive );
- FmLogger::log( logString );
+ FM_LOG( logString );
logString = "Password set error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
if( err == KErrNone ){
return FmErrNone;
@@ -391,7 +391,7 @@
int err( fs.SetVolumeLabel( newName, drive ));
QString logString = "Rename error:" + QString::number( err );
- FmLogger::log( logString );
+ FM_LOG( logString );
if( err == KErrNone ){
return FmErrNone;
@@ -410,7 +410,7 @@
return FmErrWrongParam;
}
QString logString = "FmUtils::ejectDrive start";
- FmLogger::log( logString );
+ FM_LOG( logString );
TInt drive = 0;
drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
@@ -667,14 +667,14 @@
{
QString logString;
logString = QString( "checkFolderToDriveFilter: " ) + path;
- FmLogger::log( logString );
+ FM_LOG( logString );
QString checkedPath = fillPathWithSplash( path );
logString = QString( "checkFolderToDriveFilter_fillPathWithSplash: " ) + checkedPath;
- FmLogger::log( logString );
+ FM_LOG( logString );
if( checkedPath.compare( Folder_C_Data, Qt::CaseInsensitive ) == 0 ) {
- FmLogger::log( QString( " change from c:/data/ to C:/" ) );
+ FM_LOG( QString( " change from c:/data/ to C:/" ) );
return Drive_C;
}
return path;
@@ -685,7 +685,7 @@
{
// Used to check if path is accessable, very important feature
// and will return filemanager error.
- FmLogger::log( QString( "isPathAccessabel:" ) + path );
+ FM_LOG( QString( "isPathAccessabel:" ) + path );
if( path.isEmpty() ) {
return FmErrPathNotExist;
}
@@ -693,49 +693,49 @@
// used to filter locked/ejected/corrupted drive
// check if drive is available, no matter if it is a drive, a folder, or a file.
if( !isDriveAvailable( path ) ) {
- FmLogger::log( QString( "isPathAccessabel false: path is drive and not available" ) );
+ FM_LOG( QString( "isPathAccessabel false: path is drive and not available" ) );
return FmErrDriveNotAvailable;
}
QFileInfo fileInfo( path );
if( fileInfo.absoluteFilePath().contains( Drive_C, Qt::CaseInsensitive ) &&
!fileInfo.absoluteFilePath().contains( Folder_C_Data, Qt::CaseInsensitive ) ) {
- FmLogger::log( QString( "isPathAccessabel false: path contain C and not in data folder" ) );
+ FM_LOG( QString( "isPathAccessabel false: path contain C and not in data folder" ) );
return FmErrPathDenied;
}
if( !checkDriveAccessFilter( FmUtils::getDriveNameFromPath( fileInfo.absoluteFilePath() ) ) ){
return FmErrDriveDenied;
}
if( !fileInfo.exists() ) {
- FmLogger::log( QString( "isPathAccessabel false: path not exist" ) );
+ FM_LOG( QString( "isPathAccessabel false: path not exist" ) );
return FmErrPathNotExist;
}
- FmLogger::log( QString( "isPathAccessabel FmErrNone" ) );
+ FM_LOG( QString( "isPathAccessabel FmErrNone" ) );
return FmErrNone;
}
// only used to check drive, when MMC is not inserted, also return false
bool FmUtils::isDriveAvailable( const QString &path )
{
- FmLogger::log( QString( "isDriveAvailable:" ) + path );
+ FM_LOG( QString( "isDriveAvailable:" ) + path );
if( path.isEmpty() ) {
return false;
}
FmDriverInfo::DriveState driveState = queryDriverInfo( path ).driveState();
if( ( driveState & FmDriverInfo::EDriveAvailable ) ) {
- FmLogger::log( QString( "isDriveAvailable true" ) );
+ FM_LOG( QString( "isDriveAvailable true" ) );
return true;
}
- FmLogger::log( QString( "isDriveAvailable false" ) );
+ FM_LOG( QString( "isDriveAvailable false" ) );
return false;
}
void FmUtils::getDriveList( QStringList &driveList, bool isHideUnAvailableDrive )
{
if( isHideUnAvailableDrive ) {
- FmLogger::log( QString( "getDriveList HideUnAvailableDrive_true" ) );
+ FM_LOG( QString( "getDriveList HideUnAvailableDrive_true" ) );
} else {
- FmLogger::log( QString( "getDriveList HideUnAvailableDrive_false" ) );
+ FM_LOG( QString( "getDriveList HideUnAvailableDrive_false" ) );
}
QFileInfoList infoList = QDir::drives();
--- a/filemanager/src/inc/fmutils_win.cpp Fri Jul 09 11:17:55 2010 +0800
+++ b/filemanager/src/inc/fmutils_win.cpp Fri Jul 23 11:12:24 2010 +0800
@@ -290,14 +290,14 @@
#ifdef _DEBUG_HIDE_VIEWFOLDER_WINDOWS_
QString logString;
logString = QString( "checkFolderToDriveFilter: " ) + path;
- FmLogger::log( logString );
+ FM_LOG( logString );
QString checkedPath = fillPathWithSplash( path );
logString = QString( "checkFolderToDriveFilter_fillPathWithSplash: " ) + checkedPath;
- FmLogger::log( logString );
+ FM_LOG( logString );
if( checkedPath.compare( QString( "C:/data/"), Qt::CaseInsensitive ) == 0 ) {
- FmLogger::log( QString( " change from c:/data/ to C:/" ) );
+ FM_LOG( QString( " change from c:/data/ to C:/" ) );
return QString( "C:/" );
}
#endif