--- a/filemanager/src/filemanager/filemanager.pri Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/filemanager.pri Wed Aug 18 09:39:39 2010 +0300
@@ -36,10 +36,10 @@
src/operationservice/fmoperationthread.h \
src/operationservice/fmoperationbase.h \
src/operationservice/fmoperationresultprocesser.h \
- src/operationservice/fmoperationcopy.h \
- src/operationservice/fmoperationmove.h \
+ src/operationservice/fmoperationcopyormove.h \
src/operationservice/fmoperationremove.h \
src/operationservice/fmoperationformat.h \
+ src/operationservice/fmoperationviewdetails.h \
src/backuprestore/fmbackupview.h \
src/backuprestore/fmbackupwidget.h \
src/backuprestore/fmrestoreview.h \
@@ -79,9 +79,9 @@
src/operationservice/fmoperationthread.cpp \
src/operationservice/fmoperationbase.cpp \
src/operationservice/fmoperationresultprocesser.cpp \
- src/operationservice/fmoperationcopy.cpp \
- src/operationservice/fmoperationmove.cpp \
+ src/operationservice/fmoperationcopyormove.cpp \
src/operationservice/fmoperationremove.cpp \
+ src/operationservice/fmoperationviewdetails.cpp \
src/backuprestore/fmbackupview.cpp \
src/backuprestore/fmbackupwidget.cpp \
src/backuprestore/fmrestoreview.cpp \
--- a/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupview.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupview.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupwidget.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -36,7 +36,7 @@
FmBackupWidget::FmBackupWidget( QGraphicsItem *parent )
-: HbWidget( parent ), mLastPressedItem( 0 ), mScrolled( 0 ), mListReleased( false )
+: HbWidget( parent )
{
init();
}
@@ -47,16 +47,12 @@
delete mModel;
}
-void FmBackupWidget::on_list_released( const QModelIndex &index )
-{
- HbDataFormModelItem *item = mModel->itemFromIndex(index);
- if( item != mLastPressedItem || mDataForm->isScrolling() || mScrolled ) {
- mScrolled = false;
- return;
- }
- mScrolled = false;
- if( item == mContentsItem ){
+void FmBackupWidget::on_list_activated( const QModelIndex &index )
+{
+ // change item data when receive activated signal
+ HbDataFormModelItem *item = mModel->itemFromIndex(index);
+ if( item == mContentsItem ){
emit changeContents();
} else if( item == mTargetItem ){
emit changeTargetDrive();
@@ -69,16 +65,6 @@
}
}
-void FmBackupWidget::on_list_pressed( const QModelIndex &index )
-{
- mLastPressedItem = mModel->itemFromIndex(index);
-}
-
-void FmBackupWidget::on_list_scrollingStarted()
-{
- mScrolled = true;
-}
-
void FmBackupWidget::init()
{
QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout( this );
@@ -91,16 +77,9 @@
mDataForm = new HbDataForm( this );
mDataForm->setModel( mModel );
vLayout->addItem( mDataForm );
-
-
- connect( mDataForm, SIGNAL( released( const QModelIndex & ) ),
- this, SLOT( on_list_released( const QModelIndex & ) ) );
-
- connect( mDataForm, SIGNAL( pressed( const QModelIndex & ) ),
- this, SLOT( on_list_pressed( const QModelIndex & ) ) );
-
- connect( mDataForm, SIGNAL( scrollingStarted() ),
- this, SLOT( on_list_scrollingStarted() ) );
+
+ connect( mDataForm, SIGNAL( activated( const QModelIndex & ) ),
+ this, SLOT( on_list_activated( const QModelIndex & ) ) );
connect( this, SIGNAL( doModelRefresh() ),
this, SLOT( refreshModel() ), Qt::QueuedConnection );
@@ -121,7 +100,7 @@
void FmBackupWidget::expandAllGroup()
{
- FmLogger::log( QString( "function expandAllGroup start" ) );
+ FM_LOG( QString( "function expandAllGroup start" ) );
mDataForm->setModel( 0 );
mDataForm->setModel( mModel );
@@ -129,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/fmbackupwidget.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/backuprestore/fmbackupwidget.h Wed Aug 18 09:39:39 2010 +0300
@@ -50,9 +50,7 @@
void refreshModel();
private slots:
- void on_list_released( const QModelIndex &index );
- void on_list_pressed( const QModelIndex &index );
- void on_list_scrollingStarted();
+ void on_list_activated( const QModelIndex &index );
void on_changeContents();
void on_changeScheduling();
@@ -81,10 +79,6 @@
HbDataFormModelItem *mLastBackupDateItem;
FmBackupSettings *mBackupSettings;
FmBackupConfigLoader *mBackupConfigLoader;
- HbDataFormModelItem *mLastPressedItem;
-
- bool mScrolled;
- bool mListReleased;
};
#endif // FMBACKUPWIDGET_H
--- a/filemanager/src/filemanager/src/backuprestore/fmdeletebackupview.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/backuprestore/fmdeletebackupview.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/backuprestore/fmrestoreview.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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/fmcombinedquery.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmcombinedquery.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -28,7 +28,9 @@
FmCombinedQuery::FmCombinedQuery( QGraphicsItem *parent ) : FmDialog( parent ),
mSelectMode ( MultiSelectMode ), mDominantIndex ( -1 )
{
+ setObjectName( "combinedQueryDialog" );
mContentWidget = new QGraphicsWidget();
+ mContentWidget->setObjectName( "CombinedQueryContentWidget" );
setContentWidget(mContentWidget);
QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout();
@@ -38,7 +40,7 @@
vLayout->addItem( mListWidget );
mListWidget->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
-
+ mListWidget->setObjectName( "CombinedQueryListWidget" );
this->setTimeout( NoTimeout );
mContentWidget->setLayout( vLayout );
--- a/filemanager/src/filemanager/src/components/fmdialog.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmdialog.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -50,6 +50,7 @@
void FmDialog::setPrimaryAction( HbAction *action )
{
+ action->setObjectName( "primaryAction" );
QList<QAction *> actionList = QGraphicsWidget::actions();
if (actionList.size() == 0) {
QGraphicsWidget::addAction(action);
@@ -74,9 +75,12 @@
void FmDialog::setSecondaryAction( HbAction *action )
{
+ action->setObjectName( "secondaryAction" );
QList<QAction *> actionList = QGraphicsWidget::actions();
if (actionList.size() == 0) {
- QGraphicsWidget::addAction(new HbAction(hbTrId("Ok")));
+ HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_ok"));
+ primaryAction->setObjectName( "primaryAction" );
+ QGraphicsWidget::addAction(primaryAction);
QGraphicsWidget::addAction(action);
} else if (actionList.size() == 1) {
QGraphicsWidget::addAction(action);
--- a/filemanager/src/filemanager/src/components/fmdlgutils.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmdlgutils.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -32,33 +32,29 @@
#include <hblabel.h>
#include <hbaction.h>
-
-FmDlgUtils::FmDlgUtils( void )
+
+/*
+ Private Constructor
+*/
+FmDlgUtils::FmDlgUtils()
{
}
-FmDlgUtils::~FmDlgUtils( void )
+/*!
+ Destructor
+*/
+FmDlgUtils::~FmDlgUtils()
{
}
-HbAction *FmDlgUtils::executeDialog( FmDialog *dialog, const QString &associatedDrives )
-{
- for( int i = 0; i < associatedDrives.length(); i++ ) {
- QString drive( associatedDrives[i] + QString( ":/" ) );
- if( !FmUtils::isDriveAvailable( drive ) ) {
- FmLogger::log( "executeDialog return 0_ " + associatedDrives );
- return 0;
- }
- }
-
- FmDlgCloseUnit dlgCloseUnit( dialog );
- dlgCloseUnit.addAssociatedDrives( associatedDrives );
- FmViewManager::viewManager()->addDlgCloseUnit( &dlgCloseUnit );
- HbAction* action = dialog->exec();
- FmViewManager::viewManager()->removeDlgCloseUnit( &dlgCloseUnit );
- return action;
-}
-
+/*!
+ Shows single select setting query dialog
+ \a title used for title text
+ \a textList used for text list for available settings
+ \a selectedIndex used for storing selected index
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if selection made, otherwise false
+*/
bool FmDlgUtils::showSingleSettingQuery(
const QString &title,
const QStringList &textList,
@@ -128,6 +124,15 @@
return ret;
}
+/*!
+ Shows multi select setting query dialog
+ \a title used for title text
+ \a textList used for text list for available settings
+ \a selection used for storing selected indexes as bitmask
+ \a dominantIndex used for dominant index for select all behaviour
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if selection made, otherwise false
+*/
bool FmDlgUtils::showMultiSettingQuery(
const QString &title,
const QStringList &textList,
@@ -203,6 +208,13 @@
return ret;
}
+/*!
+ Shows time setting query dialog
+ \a title used for title text
+ \a time used for selected time
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if selection made, otherwise false
+*/
bool FmDlgUtils::showTimeSettingQuery(
const QString &title, QTime &time, const QString &associatedDrives )
{
@@ -245,23 +257,31 @@
return ret;
}
+/*!
+ Shows text query dialog
+ \a title used for title text
+ \a text used for receiving user input text
+ \a validRegExpStringList used for set valid regExp string list
+ \a maxLength used for setting max length of input text
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ Set \a isReturnFalseWhenNoTextChanged true if need make return value as true while no text changed
+ return true if text change is made, otherwise false
+*/
bool FmDlgUtils::showTextQuery(
- const QString& title, QString& text, bool isDimPrimaryActionWhenEmpty, int maxLength,
- const QString &associatedDrives, bool isReturnFalseWhenNoTextChanged )
+ const QString& title, QString& text, QStringList validRegExpStringList,
+ int maxLength, const QString &associatedDrives, bool isReturnFalseWhenNoTextChanged )
{
bool ret( false );
bool ok ( true ); // SK return (out parameter)
- FmSingleTextQuery::Options options( 0 );
- if( isDimPrimaryActionWhenEmpty ) {
- options = FmSingleTextQuery::DimPrimereActionWhenEmpty;
- }
- FmSingleTextQuery *cQuery = new FmSingleTextQuery( options );
+ FmSingleTextQuery *cQuery = new FmSingleTextQuery();
if( maxLength != -1 ){
cQuery->setLineEditMaxLength( maxLength );
}
cQuery->setHeadingWidget( new HbLabel( title ) );
+ cQuery->setRegExpStringList( validRegExpStringList );
+
QString sk1 ( hbTrId ( "txt_common_button_ok" ) );
QString sk2 ( hbTrId ( "txt_common_button_cancel" ) );
@@ -303,17 +323,26 @@
return ret;
}
+/*!
+ Shows single-line password query dialog
+ \a title used for title text
+ \a pwd used for receiving user input password
+ \a maxLength used for setting max length of input password
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if password text is inputted, otherwise false
+*/
bool FmDlgUtils::showSinglePasswordQuery( const QString &title, QString &pwd, int maxLength, const QString &associatedDrives )
{
bool ret( false );
- FmSingleTextQuery *cQuery = new FmSingleTextQuery( FmSingleTextQuery::DimPrimereActionWhenEmpty,
- HbLineEdit::Password );
+ FmSingleTextQuery *cQuery = new FmSingleTextQuery( HbLineEdit::Password );
if( maxLength != -1 ){
cQuery->setLineEditMaxLength( maxLength );
}
cQuery->setHeadingWidget( new HbLabel( title ) );
-
+
+ // validate that length is not zero. space is acceptable character.
+ cQuery->setRegExpStringList( QStringList( Regex_ValidUnZeroLength ) );
QString sk1 ( hbTrId("txt_common_button_ok" ) );
QString sk2 ( hbTrId("txt_common_button_cancel" ) );
@@ -341,6 +370,15 @@
return ret;
}
+/*!
+ Shows mulit-line password query dialog. If two password is not equal, primary action is dimmed
+ \a firstLabel used for first line title text
+ \a secondLabel used for second line title text
+ \a pwd used for receiving user input password
+ \a maxLength used for setting max length of input password
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return true if password text is inputted, otherwise false
+*/
bool FmDlgUtils::showMultiPasswordQuery(
const QString &firstLabel, const QString &secondLabel, QString &pwd, int maxLength, const QString &associatedDrives )
{
@@ -384,19 +422,34 @@
return ret;
}
-bool FmDlgUtils::question( const QString &questionText, const QString &primaryButtonText,
- const QString &secondaryButtonText )
+/*!
+ This is a convenience function for showing a question dialog with \a questionText
+ Default buttons are Yes and No.
+*/
+bool FmDlgUtils::question( const QString &questionText,
+ HbMessageBox::StandardButtons buttons )
{
FmMessageBox msgBox;
- return msgBox.question( questionText, primaryButtonText, secondaryButtonText );
+ return msgBox.question( questionText, buttons );
}
-void FmDlgUtils::information( const QString &informationText )
+/*!
+ This is a convenience function for showing an information dialog with \a informationText
+ Default button is OK.
+*/
+void FmDlgUtils::information( const QString &informationText,
+ HbMessageBox::StandardButtons buttons )
{
FmMessageBox msgBox;
- return msgBox.information( informationText );
+ return msgBox.information( informationText, buttons );
}
+/*!
+ Shows query dialog for select backup drive
+ \a title used for title text
+ only backup target drives will be shown.
+ return selected drive, and empty string for cancel.
+*/
QString FmDlgUtils::showBackupDriveQuery( const QString& title )
{
QString ret;
@@ -415,3 +468,28 @@
delete cQuery;
return ret;
}
+
+/*
+ Private function used to popup \a dialog
+ If want popup dialog in class FmDlgUtils, please call this function.
+ Dialog will be closed as canceled while drive in \a associatedDrives is removed
+ return selected action.
+*/
+HbAction *FmDlgUtils::executeDialog( FmDialog *dialog, const QString &associatedDrives )
+{
+ for( int i = 0; i < associatedDrives.length(); i++ ) {
+ QString drive( associatedDrives[i] + QString( ":/" ) );
+ if( !FmUtils::isDriveAvailable( drive ) ) {
+ FM_LOG( "executeDialog return 0_ " + associatedDrives );
+ return 0;
+ }
+ }
+
+ FmDlgCloseUnit dlgCloseUnit( dialog );
+ dlgCloseUnit.addAssociatedDrives( associatedDrives );
+
+ FmViewManager::viewManager()->addDlgCloseUnit( &dlgCloseUnit );
+ HbAction* action = dialog->exec();
+ FmViewManager::viewManager()->removeDlgCloseUnit( &dlgCloseUnit );
+ return action;
+}
--- a/filemanager/src/filemanager/src/components/fmdlgutils.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmdlgutils.h Wed Aug 18 09:39:39 2010 +0300
@@ -26,38 +26,25 @@
#include <QTime>
#include <hbglobal.h>
+#include <hbmessagebox.h>
class FmDialog;
class HbAction;
+/*!
+ \class FmDlgUtils
+ \brief The class FmDlgUtils is static utility class. Used to popup dialogs
+ */
class FmDlgUtils : public QObject
{
Q_OBJECT
public:
-
- /**
- * Shows single select setting page
- *
- * @param title Title text
- * @param textList Text list for available settings
- * @param selectedIndex For storing selected index
- * @return true if selection made, otherwise false
- */
static bool showSingleSettingQuery(
const QString &title,
const QStringList &textList,
int &selectedIndex,
const QString &associatedDrives = QString() );
- /**
- * Shows multi select setting page
- *
- * @param title Title text
- * @param textList Text list for available settings
- * @param selection For storing selected indexes as bitmask
- * @param dominantIndex Dominant index for select all behaviour
- * @return true if selection made, otherwise false
- */
static bool showMultiSettingQuery(
const QString &title,
const QStringList &textList,
@@ -65,45 +52,33 @@
int dominantIndex,
const QString &associatedDrives = QString() );
- /**
- * Shows time setting page
- *
- * @param title Title text id
- * @param time Selected time
- * @return true if selection made, otherwise false
- */
static bool showTimeSettingQuery(
const QString &title, QTime &time,
- const QString &associatedDrives = QString() );
+ const QString &associatedDrives = QString() );
static bool showTextQuery(
- const QString &title, QString &driveName, bool isDimPrimaryActionWhenEmpty, int maxLength = -1,
- const QString &associatedDrives = QString(), bool isReturnFalseWhenNoTextChanged = true );
+ const QString &title, QString &text, QStringList validRegExpStringList = QStringList( Regex_ValidUnEmpty ),
+ int maxLength = -1, const QString &associatedDrives = QString(), bool isReturnFalseWhenNoTextChanged = true );
static bool showSinglePasswordQuery(
- const QString &title, QString &pwd, int maxLength = -1,
- const QString &associatedDrives = QString() );
+ const QString &title, QString &pwd, int maxLength = -1,
+ const QString &associatedDrives = QString() );
static bool showMultiPasswordQuery(
- const QString &firstLabel, const QString &secondLabel, QString &pwd, int maxLength = -1,
- const QString &associatedDrives = QString() );
+ const QString &firstLabel, const QString &secondLabel, QString &pwd, int maxLength = -1,
+ const QString &associatedDrives = QString() );
- static bool question( const QString &questionText, const QString &primaryButtonText = QString( hbTrId("Yes") ),
- const QString &secondaryButtonText = QString( hbTrId("No") ) );
+ static bool question( const QString &questionText,
+ HbMessageBox::StandardButtons buttons = HbMessageBox::Yes | HbMessageBox::No );
- static void information( const QString &informationText );
-
- /**
- * Query drive for backup
- *
- * @param title Title for query dialog
- * @return selected drive name. empty for cancel.
- */
+ static void information( const QString &informationText,
+ HbMessageBox::StandardButtons buttons = HbMessageBox::Ok );
+
static QString showBackupDriveQuery( const QString& title );
- ~FmDlgUtils(void);
+ ~FmDlgUtils();
private:
- FmDlgUtils(void);
+ FmDlgUtils();
static HbAction *executeDialog( FmDialog *dialog, const QString &associatedDrives );
};
--- a/filemanager/src/filemanager/src/components/fmdrivedetailstype.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmdrivedetailstype.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmdrivedetailstype.h Wed Aug 18 09:39:39 2010 +0300
@@ -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/fmdrivequery.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmdrivequery.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -25,13 +25,16 @@
FmDriveQuery::FmDriveQuery( QGraphicsItem *parent ) : FmDialog( parent )
{
+ setObjectName( "driveQueryDialog" );
mContentWidget = new QGraphicsWidget();
+ mContentWidget->setObjectName( "driveQueryContentWidget" );
setContentWidget(mContentWidget);
QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout();
vLayout->setOrientation( Qt::Vertical );
mListView = new HbListView();
+ mListView->setObjectName( "driveQueryListView" );
vLayout->addItem( mListView );
mListView->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
--- a/filemanager/src/filemanager/src/components/fmmessagebox.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmmessagebox.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -19,18 +19,25 @@
#include "fmmessagebox.h"
#include <hbmessagebox.h>
-void FmMessageBox::information( const QString &informationText )
+/*!
+ This is a convenience function for showing an information dialog with \a informationText
+*/
+void FmMessageBox::information( const QString &informationText,
+ HbMessageBox::StandardButtons buttons )
{
HbMessageBox::information ( informationText,
- this, SLOT(dialogClosed(HbAction*)) );
+ this, SLOT(dialogClosed(HbAction*)), buttons );
mEventLoop.exec();
}
-bool FmMessageBox::question( const QString &questionText, const QString &primaryButtonText,
- const QString &secondaryButtonText )
+/*!
+ This is a convenience function for showing a question dialog with \a questionText
+*/
+bool FmMessageBox::question( const QString &questionText,
+ HbMessageBox::StandardButtons buttons )
{
HbMessageBox::question ( questionText,
- this, SLOT(dialogClosed(HbAction*)), primaryButtonText, secondaryButtonText );
+ this, SLOT(dialogClosed(HbAction*)), buttons );
mEventLoop.exec();
return mRet;
}
--- a/filemanager/src/filemanager/src/components/fmmessagebox.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmmessagebox.h Wed Aug 18 09:39:39 2010 +0300
@@ -33,10 +33,12 @@
~FmMessageBox()
{
}
- void information( const QString &informationText );
+ void information( const QString &informationText,
+ HbMessageBox::StandardButtons buttons );
- bool question( const QString &questionText, const QString &primaryButtonText,
- const QString &secondaryButtonText );
+ bool question( const QString &questionText,
+ HbMessageBox::StandardButtons buttons );
+
public slots:
void dialogClosed(HbAction *action);
private:
--- a/filemanager/src/filemanager/src/components/fmmultitextquery.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmmultitextquery.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -37,29 +37,35 @@
void FmMultiTextQuery::init()
{
+ setObjectName( "MultiTextQuery" );
setDismissPolicy( HbPopup::NoDismiss );
mContentWidget = new HbWidget();
+ mContentWidget->setObjectName( "MultiTextContentWidget" );
setContentWidget( mContentWidget );
QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout();
vLayout->setOrientation( Qt::Vertical );
mFirstLabel = new HbLabel();
+ mFirstLabel->setObjectName( "MutiTextFirstLabel" );
mFirstLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
vLayout->addItem( mFirstLabel );
mFirstEdit = new HbLineEdit();
mFirstEdit->setEchoMode( mEchoMode );
mFirstEdit->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
+ mFirstEdit->setObjectName("firstLineEdit");
vLayout->addItem( mFirstEdit );
mSecondLabel = new HbLabel();
mSecondLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
+ mSecondLabel->setObjectName( "MutiTextSecondLabel" );
vLayout->addItem( mSecondLabel );
mSecondEdit = new HbLineEdit();
mSecondEdit->setEchoMode( mEchoMode );
mSecondEdit->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
+ mSecondEdit->setObjectName("secondLineEdit");
vLayout->addItem( mSecondEdit );
mContentWidget->setLayout( vLayout );
--- a/filemanager/src/filemanager/src/components/fmsingletextquery.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmsingletextquery.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -19,14 +19,14 @@
#include "fmsingletextquery.h"
#include <QGraphicsLinearLayout>
+#include <QRegExp>
#include <hbwidget.h>
#include <hblineedit.h>
#include <hbaction.h>
-FmSingleTextQuery::FmSingleTextQuery( Options options,
- HbLineEdit::EchoMode echoMode, QGraphicsItem *parent ) :
- FmDialog( parent ), mOptions( options ), mEchoMode( echoMode )
+FmSingleTextQuery::FmSingleTextQuery( HbLineEdit::EchoMode echoMode, QGraphicsItem *parent ) :
+ FmDialog( parent ), mEchoMode( echoMode )
{
init();
}
@@ -37,9 +37,12 @@
void FmSingleTextQuery::init()
{
+ setObjectName( "SingleTextQuery " );
setDismissPolicy( HbPopup::NoDismiss );
mContentWidget = new HbWidget();
- setContentWidget( mContentWidget );
+ mContentWidget->setObjectName( "SingleTextContentWidget" );
+ setContentWidget( mContentWidget );
+
QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout();
vLayout->setOrientation( Qt::Vertical );
@@ -47,6 +50,7 @@
mTextEdit = new HbLineEdit();
mTextEdit->setEchoMode( mEchoMode );
mTextEdit->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
+ mTextEdit->setObjectName( "textLineEdit" );
vLayout->addItem( mTextEdit );
mContentWidget->setLayout( vLayout );
@@ -74,13 +78,26 @@
mTextEdit->setMaxLength( length );
}
+void FmSingleTextQuery::setRegExpStringList( QStringList regExpStringList )
+{
+ mRegExpStringList = regExpStringList;
+}
+
void FmSingleTextQuery::checkActions()
{
- if( mOptions & DimPrimereActionWhenEmpty ) {
- if( !mTextEdit->text().isEmpty() ){
- this->primaryAction()->setEnabled( true );
- } else {
- this->primaryAction()->setEnabled( false );
+ // check if all regExp match, disable primary action if not match
+ bool validateResult = true;
+ foreach( const QString ®ExpString, mRegExpStringList ) {
+ if( !regExpString.isEmpty() ) {
+ QRegExp regExp( regExpString );
+ if( !regExp.exactMatch( mTextEdit->text() ) ) {
+ validateResult = false;
+ }
}
}
+ if( validateResult ) {
+ this->primaryAction()->setEnabled( true );
+ } else {
+ this->primaryAction()->setEnabled( false );
+ }
}
--- a/filemanager/src/filemanager/src/components/fmsingletextquery.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmsingletextquery.h Wed Aug 18 09:39:39 2010 +0300
@@ -28,23 +28,18 @@
{
Q_OBJECT
public:
- enum Option
- {
- DimPrimereActionWhenEmpty = 0x00000001
- };
- Q_DECLARE_FLAGS(Options, Option)
- FmSingleTextQuery( Options options = 0,
- HbLineEdit::EchoMode echoMode = HbLineEdit::Normal, QGraphicsItem *parent = 0 );
+ FmSingleTextQuery( HbLineEdit::EchoMode echoMode = HbLineEdit::Normal, QGraphicsItem *parent = 0 );
~FmSingleTextQuery();
public:
void setLineEditText( const QString &text );
QString getLineEditText();
void setLineEditMaxLength( int length );
+ void setRegExpStringList( QStringList regExpStringList );
public slots:
- void checkActions();
+ void checkActions();
private:
void init();
@@ -52,8 +47,10 @@
private:
HbWidget *mContentWidget;
HbLineEdit *mTextEdit;
- Options mOptions;
HbLineEdit::EchoMode mEchoMode;
+
+ // used to check if input text is vaild. Disable primary action when text is not vaild
+ QStringList mRegExpStringList;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(FmSingleTextQuery::Options)
+
#endif
--- a/filemanager/src/filemanager/src/components/fmtimequery.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmtimequery.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -26,15 +26,16 @@
FmTimeQuery::FmTimeQuery( QGraphicsItem *parent ) : FmDialog( parent )
{
-
+ setObjectName( "timeQueryDialog" );
mContentWidget = new QGraphicsWidget();
setContentWidget(mContentWidget);
-
+ mContentWidget->setObjectName( "timeQueryContentWidget" );
QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout();
vLayout->setOrientation( Qt::Vertical );
mTimeWidget = new HbDateTimeEdit();
- vLayout->addItem(mTimeWidget);
+ mTimeWidget->setObjectName( "timeQueryTimeWidget" );
+ vLayout->addItem( mTimeWidget );
mTimeWidget->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
mTimeWidget->setDisplayFormat( "hh:mm" );
--- a/filemanager/src/filemanager/src/components/fmviewdetailsdialog.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmviewdetailsdialog.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -61,10 +61,13 @@
void FmViewDetailsDialog::init()
{
+ setObjectName( "viewDetailsDialog" );
mHeaderLabel = new HbLabel( this );
setHeadingWidget( mHeaderLabel );
+ mHeaderLabel->setObjectName( "viewDetailsHeaderLabel" );
mListView = new HbListView( this );
+ mListView->setObjectName( "viewDetailsListView" );
setContentWidget( mListView );
// init QStardardItemModel as 0 row and 1 column
@@ -287,46 +290,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 +345,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 +354,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 +364,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/components/fmviewdetailsitem.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/components/fmviewdetailsitem.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -81,11 +81,13 @@
mDetailsContentLabel = new HbLabel("");
mDetailsContentLabel->setFontSpec( HbFontSpec( HbFontSpec::Primary ) );
+ mDetailsContentLabel->setObjectName( "detaisContentLabel" );
mLayout->addItem( mDetailsContentLabel );
mLayout->setAlignment( mDetailsContentLabel, Qt::AlignLeft );
mDetailsLabel = new HbLabel("");
mDetailsLabel->setFontSpec( HbFontSpec( HbFontSpec::Secondary ) );
+ mDetailsLabel->setObjectName( "detailsLabel" );
mLayout->addItem( mDetailsLabel );
mLayout->setAlignment( mDetailsLabel, Qt::AlignLeft );
--- a/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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() );
@@ -128,6 +127,7 @@
mContextMenu->clearActions();
}
FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
+ FmDriverInfo::DriveType driveType = driverInfo.driveType();
FmDriverInfo::DriveState state = driverInfo.driveState();
if( !( state & FmDriverInfo::EDriveNotPresent ) ) {
if( state & FmDriverInfo::EDriveAvailable ) {
@@ -135,76 +135,76 @@
viewAction->setObjectName( "viewAction" );
viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) );
mContextMenu->addAction( viewAction );
-
- //state = 0x210;
-
connect( viewAction, SIGNAL( triggered() ),
this, SLOT( on_viewAction_triggered() ), Qt::QueuedConnection );
- }
-
- if( ( state & FmDriverInfo::EDriveAvailable ) && ( state & FmDriverInfo::EDriveRemovable ) && !( state & FmDriverInfo::EDriveMassStorage ) ){
- // MMC or Usb memory
- if ( driverInfo.volumeName().length() ){
- HbAction *renameAction = new HbAction();
- renameAction->setObjectName( "renameAction" );
- renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) );
- mContextMenu->addAction( renameAction );
-
- connect( renameAction, SIGNAL( triggered() ),
- this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection );
- }
- else{
- HbAction *nameAction = new HbAction();
- nameAction->setObjectName( "nameAction" );
- nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) );
- mContextMenu->addAction( nameAction );
-
- connect( nameAction, SIGNAL( triggered() ),
- this, SLOT( on_nameAction_triggered() ), Qt::QueuedConnection );
- }
- if( !( state & FmDriverInfo::EDriveUsbMemory ) ) { // MMC
- if( state & FmDriverInfo::EDrivePasswordProtected ){
- HbAction *changePwdAction = new HbAction();
- changePwdAction->setObjectName( "changePwdAction" );
- changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) );
- mContextMenu->addAction( changePwdAction );
+
+ if( driveType == FmDriverInfo::EDriveTypeMemoryCard || driveType == FmDriverInfo::EDriveTypeUsbMemory ) {
+ // MMC or Usb memory
+
+ // Name/Rename action
+ if ( driverInfo.volumeName().length() ){
+ HbAction *renameAction = new HbAction();
+ renameAction->setObjectName( "renameAction" );
+ renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) );
+ mContextMenu->addAction( renameAction );
+
+ connect( renameAction, SIGNAL( triggered() ),
+ this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection );
+ } else {
+ HbAction *nameAction = new HbAction();
+ nameAction->setObjectName( "nameAction" );
+ nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) );
+ mContextMenu->addAction( nameAction );
- HbAction *removePwdAction = new HbAction();
- removePwdAction->setObjectName( "removePwdAction" );
- removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) );
- mContextMenu->addAction( removePwdAction );
-
- connect( changePwdAction, SIGNAL( triggered() ),
- this, SLOT( on_changePwdAction_triggered() ), Qt::QueuedConnection );
- connect( removePwdAction, SIGNAL( triggered() ),
- this, SLOT( on_removePwdAction_triggered() ), Qt::QueuedConnection );
+ connect( nameAction, SIGNAL( triggered() ),
+ this, SLOT( on_nameAction_triggered() ), Qt::QueuedConnection );
}
- else{
- HbAction *setPwdAction = new HbAction();
- setPwdAction->setObjectName( "setPwdAction" );
- setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) );
- mContextMenu->addAction( setPwdAction );
-
- connect( setPwdAction, SIGNAL( triggered() ),
- this, SLOT( on_setPwdAction_triggered() ), Qt::QueuedConnection );
+
+ // Set/Change/Remove password action
+ if( driveType == FmDriverInfo::EDriveTypeMemoryCard ) { // MMC
+ if( state & FmDriverInfo::EDrivePasswordProtected ){
+ HbAction *changePwdAction = new HbAction();
+ changePwdAction->setObjectName( "changePwdAction" );
+ changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) );
+ mContextMenu->addAction( changePwdAction );
+
+ HbAction *removePwdAction = new HbAction();
+ removePwdAction->setObjectName( "removePwdAction" );
+ removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) );
+ mContextMenu->addAction( removePwdAction );
+
+ connect( changePwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_changePwdAction_triggered() ), Qt::QueuedConnection );
+ connect( removePwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_removePwdAction_triggered() ), Qt::QueuedConnection );
+ }
+ else{
+ HbAction *setPwdAction = new HbAction();
+ setPwdAction->setObjectName( "setPwdAction" );
+ setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) );
+ mContextMenu->addAction( setPwdAction );
+
+ connect( setPwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_setPwdAction_triggered() ), Qt::QueuedConnection );
+ }
}
+
+ // Eject action
+ if( state & FmDriverInfo::EDriveEjectable ){
+ HbAction *ejectAction = new HbAction();
+ ejectAction->setObjectName( "ejectAction" );
+ ejectAction->setText( hbTrId( "txt_fmgr_menu_eject" ) );
+ mContextMenu->addAction( ejectAction );
+
+ connect( ejectAction, SIGNAL( triggered() ),
+ this, SLOT( on_ejectAction_triggered() ), Qt::QueuedConnection );
+ }
}
}
- if( state & FmDriverInfo::EDriveEjectable ){
- HbAction *ejectAction = new HbAction();
- ejectAction->setObjectName( "ejectAction" );
- ejectAction->setText( hbTrId( "txt_fmgr_menu_eject" ) );
- mContextMenu->addAction( ejectAction );
-
- connect( ejectAction, SIGNAL( triggered() ),
- this, SLOT( on_ejectAction_triggered() ), Qt::QueuedConnection );
- }
-
- #ifndef _DEBUG_ENABLE_FORMATMENU_
- if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted )
+ // Format action
+ if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted )
|| ( state & FmDriverInfo::EDriveLocked ) ){
- #endif
HbAction *formatAction = new HbAction();
formatAction->setObjectName( "formatAction" );
formatAction->setText( hbTrId( "txt_fmgr_menu_format" ) );
@@ -212,20 +212,23 @@
connect( formatAction, SIGNAL( triggered() ),
this, SLOT( on_formatAction_triggered() ), Qt::QueuedConnection );
- #ifndef _DEBUG_ENABLE_FORMATMENU_
- }
- #endif
-
- if( state & FmDriverInfo::EDriveLocked ){
- HbAction *unLockedAction = new HbAction();
- unLockedAction->setObjectName( "unLockedAction" );
- unLockedAction->setText( hbTrId( "Unlock" ) );
- mContextMenu->addAction( unLockedAction );
-
- connect( unLockedAction, SIGNAL( triggered() ),
- this, SLOT( on_unLockedAction_triggered() ), Qt::QueuedConnection );
}
}
+
+ // Unlock action
+ // put ouside of !EDriveNotPresent judgement so that
+ // user could unlock drive if connected to PC with mass storage mode
+ if( state & FmDriverInfo::EDriveLocked ){
+ HbAction *unLockedAction = new HbAction();
+ unLockedAction->setObjectName( "unLockedAction" );
+ unLockedAction->setText( hbTrId( "Unlock" ) );
+ mContextMenu->addAction( unLockedAction );
+
+ connect( unLockedAction, SIGNAL( triggered() ),
+ this, SLOT( on_unLockedAction_triggered() ), Qt::QueuedConnection );
+ }
+
+ // Pop up menu or open drive
if( mContextMenu->actions().count() > 0 ) {
mContextMenu->setPreferredPos( coords );
mContextMenu->open();
@@ -257,13 +260,21 @@
return;
}
- QString title( hbTrId( "Drive name ") );
- QString volumeName = driverInfo.volumeName();
-
+ QString title( hbTrId( "Drive name ") );
+ //save the volume status, empty or set
+ bool needToSetVolume = false;
+ QString volumeName = FmUtils::getVolumeNameWithDefaultNameIfNull( diskName, needToSetVolume );
+ QString oldVolumeName( volumeName );
QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
- while( FmDlgUtils::showTextQuery( title, volumeName, false, FmMaxLengthofDriveName, associatedDrives ) ){
+ //use isReturnFalseWhenNoTextChanged = false in order that FmUtils::renameDrive( driveName, volumeName ) will
+ //be excuted at lease once to set the volume name.
+ while( FmDlgUtils::showTextQuery( title, volumeName, QStringList(), FmMaxLengthofDriveName, associatedDrives, false ) ){
+ //if volume is not set or oldVolumeName != volumeName , FmUtils::renameDrive will be called
+ if ( oldVolumeName == volumeName && !needToSetVolume ) {
+ break;
+ }
int err = FmUtils::renameDrive( diskName, volumeName );
- if ( err == FmErrNone ){
+ if ( err == FmErrNone ) {
FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
mModel->refresh();
break;
@@ -318,7 +329,7 @@
QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) {
if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ){
- if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd ) ){
+ if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ){
if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
FmDlgUtils::information( hbTrId( "The password has been changed!" ) );
} else {
@@ -372,7 +383,7 @@
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
//Do not add associatedDrives as Locked MMC is not available Drive but only present Drive
- while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd ) ) {
+ while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword ) ) {
int err = FmUtils::unlockDrive( diskName, oldPwd );
if( err == FmErrNone ) {
FmDlgUtils::information( hbTrId( "The memory is unlocked!" ) );
--- a/filemanager/src/filemanager/src/fmdriverlistwidget.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmdriverlistwidget.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmdriverview.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmdriverview.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 )
@@ -303,7 +303,7 @@
QString filePath( mModel->filePath( item->modelIndex() ) );
- QString formatFilePath( FmUtils::formatPath( filePath ) );
+ QString formatFilePath( FmUtils::fillPathWithSplash( filePath ) );
QFileInfo fileInfo( filePath );
if( ( fileInfo.isFile() ) || ( fileInfo.isDir() && !( FmUtils::isDefaultFolder( formatFilePath ) ) ) ){
@@ -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 )
{
@@ -527,6 +518,11 @@
mEmptyTipLabel->setPlainText( hbTrId( "Drive can not be opened " ) );
}
setStyle( LabelStyle );
+ //hide search panel when the drive is removed
+ if ( mSearchPanel->isVisible() ){
+ mSearchPanel->hide();
+ mLayout->removeItem( mSearchPanel );
+ }
emit setEmptyMenu( true );
break;
}
@@ -708,9 +704,12 @@
QString filePath = mModel->filePath( mCurrentItem->modelIndex() );
QFileInfo fileInfo = mModel->fileInfo( mCurrentItem->modelIndex() );
int maxFileNameLength = FmUtils::getMaxFileNameLength();
+ // regExpList used to disable primary action of text query dialog if input text is not match
+ QStringList regExpList = (QStringList() << Regex_ValidFileFolderName << Regex_ValidNotEndWithDot );
+
QString oldSuffix( fileInfo.suffix() );
QString newName( fileInfo.fileName() );
- while( FmDlgUtils::showTextQuery( hbTrId( "Enter new name for %1" ).arg( newName ), newName, true,
+ while( FmDlgUtils::showTextQuery( hbTrId( "Enter new name for %1" ).arg( newName ), newName, regExpList,
maxFileNameLength, QString() , true ) ){
// remove whitespace from the start and the end.
newName = newName.trimmed();
@@ -719,7 +718,8 @@
QFileInfo newFileInfo( newTargetPath );
QString errString;
// check if name/path is available for use
- if( !FmUtils::checkNewFolderOrFile( newTargetPath, errString ) ) {
+ // add new Name to check, in order to avoid problem of newName is empty
+ if( !FmUtils::checkNewFolderOrFile( newName, newTargetPath, errString ) ) {
FmDlgUtils::information( errString );
continue;
}
@@ -727,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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfilebrowsewidget.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfileview.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 );
@@ -396,25 +398,25 @@
QString associatedDrive = FmUtils::getDriveLetterFromPath( mWidget->currentPath().absoluteFilePath() );
QString path = FmUtils::fillPathWithSplash( mWidget->currentPath().absoluteFilePath() );
QString dirName = createDefaultFolderName( path );
-
+ QStringList regExpList = (QStringList() << Regex_ValidFileFolderName << Regex_ValidNotEndWithDot );
+
QDir dir( path );
if( dir.exists() ) {
while( FmDlgUtils::showTextQuery( hbTrId( "txt_fmgr_title_new_folder" ), dirName,
- true, maxFileNameLength, associatedDrive , false ) ){
+ regExpList, maxFileNameLength, associatedDrive , false ) ){
// remove whitespace from the start and the end.
dirName = dirName.trimmed();
QString newTargetPath = FmUtils::fillPathWithSplash(
dir.absolutePath() ) + dirName;
QString errString;
// check if name/path is available for use
- if( !FmUtils::checkNewFolderOrFile( newTargetPath, errString ) ) {
+ if( !FmUtils::checkNewFolderOrFile( dirName, newTargetPath, errString ) ) {
FmDlgUtils::information( errString );
continue;
}
if( !dir.mkdir( dirName ) ) {
FmDlgUtils::information( hbTrId("Operation failed!") );
}
- refreshModel( path );
break;
}
@@ -444,9 +446,9 @@
}
}
-void FmFileView::refreshModel( const QString &path )
+void FmFileView::on_driveChanged()
{
- mWidget->refreshModel( path );
+ mWidget->on_driveChanged();
}
void FmFileView::on_sortNameAction_triggered()
@@ -484,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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfileview.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfindresultmodel.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfindresultmodel.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfindthread.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfindthread.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmfindview.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmmainwindow.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmviewmanager.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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,16 @@
mMainWindow->addView( driverView );
mMainWindow->setCurrentView( driverView );
- connect( this, SIGNAL( refreshModel( QString ) ),
- driverView, SLOT( refreshModel( QString ) ) );
+ connect( this, SIGNAL( driveSpaceChanged() ),
+ driverView, SLOT( refreshDrive() ) );
+
+ // use Qt::QueuedConnection becuase synchronous refresh is not work well while
+ // connected with another OTG device which have more than one external drive in it.
+ // File server only give driveChanged event once, but two drive is inserted.
+ // Synchronous refresh will miss another drive.
+ // So use Qt::QueuedConnection to performance asynchronous refresh.
+ connect( this, SIGNAL( driveChanged() ),
+ driverView, SLOT( refreshDrive() ), Qt::QueuedConnection );
}
void FmViewManager::createFileView( const QString &path,
@@ -213,8 +217,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 +248,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 +260,7 @@
mMainWindow->addView( restoreView );
mMainWindow->setCurrentView( restoreView );
- connect( this, SIGNAL( refreshRestoreView() ), restoreView, SLOT( refreshRestoreView() ) );
+ connect( this, SIGNAL( driveChanged() ), restoreView, SLOT( refreshRestoreView() ) );
}
@@ -266,7 +270,7 @@
mMainWindow->addView( deleteBackupView );
mMainWindow->setCurrentView( deleteBackupView );
- connect( this, SIGNAL( refreshDeleteBackupView() ), deleteBackupView, SLOT( refreshDeleteBackupView() ) );
+ connect( this, SIGNAL( driveChanged() ), deleteBackupView, SLOT( refreshDeleteBackupView() ) );
}
@@ -274,35 +278,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 +295,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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmviewmanager.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/main.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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/fmoperationbase.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationbase.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -19,114 +19,128 @@
#include "fmoperationbase.h"
#include "fmdrivedetailstype.h"
#include <QtAlgorithms>
+/*
+ * \fn void showNote( const QString ¬e )
+ * This signal is emitted when operation needs operation service to show some note.
+ * \a note indicates the note to show.
+ */
+/* \fn void notifyWaiting( bool cancelable )
+ * This signal is emitted when operation needs operation service to wait.
+ * \a cancelable indicates whether it could be canceled.
+ */
+
+/* \fn void notifyPreparing( bool cancelable )
+ * This signal is emitted when operation needs operation service to prepare.
+ * \a cancelable indicates whether it could be canceled.
+ */
+
+/* \fn void notifyStart( bool cancelable, int maxSteps )
+ * This signal is emitted when operation starts and operation service shows progress bar.
+ * \a cancelable indicates whether it could be canceled.
+ * \a maxStep indicates the max of progress bar.
+ */
+
+/* \fn void notifyProgress( int currentStep )
+ * This signal is emitted when operation needs operation service update progress bar.
+ * \a currentStep the current step.
+ */
+
+/* \fn void notifyFinish()
+ * This signal is emitted when operation finished.
+ */
+
+/* \fn void notifyError( int error, const QString &errString )
+ * This signal is used to notify error.
+ * \a error the error id.
+ * \a errString the error string.
+ */
+
+/*
+ Constructs the base operation with
+ \a parent parent
+ \a operationType the type of current operation.
+*/
FmOperationBase::FmOperationBase( QObject *parent, FmOperationService::TOperationType operationType ) :
QObject( parent ), mOperationType( operationType )
{
}
+/*
+ Destructs the operation
+*/
FmOperationBase::~FmOperationBase()
{
}
+/*
+ Returns the current operation type
+*/
FmOperationService::TOperationType FmOperationBase::operationType()
{
return mOperationType;
}
-
-//FmOperationFormat
-//FmOperationFormat::FmOperationFormat( QObject *parent, QString mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ),
-// mDriverName( mDriverName )
-//{
-//}
-//FmOperationFormat::~FmOperationFormat()
-//{
-//}
-//
-//QString FmOperationFormat::driverName()
-//{
-// return mDriverName;
-//}
-
-//FmOperationDriveDetails
-FmOperationDriveDetails::FmOperationDriveDetails( QObject *parent, QString driverName ) :
- FmOperationBase( parent, FmOperationService::EOperationTypeDriveDetails ),
- mDriverName( driverName )
-{
-}
-FmOperationDriveDetails::~FmOperationDriveDetails()
-{
- qDeleteAll(mDetailsSizeList);
-}
-
-QString FmOperationDriveDetails::driverName()
-{
- return mDriverName;
-}
-
-QList<FmDriveDetailsSize*> &FmOperationDriveDetails::detailsSizeList()
-{
- return mDetailsSizeList;
-}
-
-//FmOperationFolderDetails
-FmOperationFolderDetails::FmOperationFolderDetails( QObject *parent, const QString folderPath ) :
- FmOperationBase( parent, FmOperationService::EOperationTypeFolderDetails ),
- mFolderPath( folderPath ),
- mNumofSubFolders( 0 ),
- mNumofFiles( 0 ),
- mSizeofFolder( 0 )
-
-{
-}
-FmOperationFolderDetails::~FmOperationFolderDetails()
+/*
+ Starts the operation, called by FmOperationThread.
+ Use empty implementation because Backup and Restore
+ are not done within thread, so they will not reimplement
+ this function.
+ \sa FmOperationThread::run
+*/
+void FmOperationBase::start( volatile bool */*isStopped*/ )
{
}
-QString FmOperationFolderDetails::folderPath()
-{
- return mFolderPath;
-}
-
-int &FmOperationFolderDetails::numofSubFolders()
+/*
+ Does some additional work before starting the operation.
+ Returns the error number.
+*/
+int FmOperationBase::prepare()
{
- return mNumofSubFolders;
-}
-
-int &FmOperationFolderDetails::numofFiles()
-{
- return mNumofFiles;
-}
-
-quint64 &FmOperationFolderDetails::sizeofFolder()
-{
- return mSizeofFolder;
+ return FmErrNone;
}
-
+/*
+ Constructs a backup operation with
+ \a parent parent
+*/
FmOperationBackup::FmOperationBackup( QObject *parent )
: FmOperationBase( parent, FmOperationService::EOperationTypeBackup )
{
}
+
+/*
+ Destructs the backup operation
+*/
FmOperationBackup::~FmOperationBackup()
{
}
-
+/*
+ Constructs a restore operation with
+ \a parent parent
+ \a selection the selected backup items
+*/
FmOperationRestore::FmOperationRestore( QObject *parent, quint64 selection )
: FmOperationBase( parent, FmOperationService::EOperationTypeRestore ), mSelection( selection )
{
}
+/*
+ Destructs the restore operation
+*/
FmOperationRestore::~FmOperationRestore()
{
}
+/*
+ Returns the backup items
+*/
quint64 FmOperationRestore::selection()
{
return mSelection;
--- a/filemanager/src/filemanager/src/operationservice/fmoperationbase.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationbase.h Wed Aug 18 09:39:39 2010 +0300
@@ -32,52 +32,23 @@
virtual ~FmOperationBase();
FmOperationService::TOperationType operationType();
+ virtual int prepare();
+ virtual void start( volatile bool *isStopped );
+
+signals:
+ void showNote( const QString ¬e );
+ void notifyWaiting( bool cancelable );
+ void notifyPreparing( bool cancelable );
+ void notifyStart( bool cancelable, int maxSteps );
+ void notifyProgress( int currentStep );
+ void notifyFinish();
+ void notifyError( int error, const QString &errString );
+
private:
FmOperationService::TOperationType mOperationType;
};
-//class FmOperationFormat : public FmOperationBase
-//{
-//public:
-// explicit FmOperationFormat( QObject *parent, QString mDriverName );
-// virtual ~FmOperationFormat();
-// QString driverName();
-//private:
-// QString mDriverName;
-//};
-
-class FmOperationDriveDetails : public FmOperationBase
-{
-public:
- explicit FmOperationDriveDetails( QObject *parent, QString driverName );
-
- virtual ~FmOperationDriveDetails();
- QString driverName();
- QList<FmDriveDetailsSize*> &detailsSizeList();
-private:
- QString mDriverName;
- QList<FmDriveDetailsSize*> mDetailsSizeList;
-};
-
-class FmOperationFolderDetails : public FmOperationBase
-{
-public:
- explicit FmOperationFolderDetails( QObject *parent, const QString folderPath );
-
- virtual ~FmOperationFolderDetails();
- QString folderPath();
- int &numofSubFolders();
- int &numofFiles();
- quint64 &sizeofFolder();
-
-private:
- QString mFolderPath;
- int mNumofSubFolders;
- int mNumofFiles;
- quint64 mSizeofFolder;
-};
-
class FmOperationBackup : public FmOperationBase
{
--- a/filemanager/src/filemanager/src/operationservice/fmoperationcopy.cpp Tue Jul 06 14:06:28 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,258 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#include "fmoperationcopy.h"
-#include "fmcommon.h"
-#include "fmoperationbase.h"
-#include "fmdrivedetailstype.h"
-#include "fmutils.h"
-
-#include <QDir>
-#include <QFileInfo>
-#include <QStringList>
-#include <QStack>
-
-
-FmOperationCopy::FmOperationCopy( QObject *parent, QStringList sourceList, QString targetPath ) :
- FmOperationBase( parent, FmOperationService::EOperationTypeCopy ),
- mSourceList( sourceList ), mTargetPath( targetPath ),
- mStop( 0 ), mTotalSize( 0 ), mErrString( 0 ), mCopiedSize( 0 ), mTotalSteps( 100 ), mCurrentStep( 0 )
-{
-}
-
-FmOperationCopy::~FmOperationCopy()
-{
-}
-
-QStringList FmOperationCopy::sourceList()
-{
- return mSourceList;
-}
-
-QString FmOperationCopy::targetPath()
-{
- return mTargetPath;
-}
-
-int FmOperationCopy::start( volatile bool *isStopped, QString *errString )
-{
- mStop = isStopped;
- mErrString = errString;
- mTotalSize = 0;
- mCopiedSize = 0;
- mCurrentStep = 0;
-
- if( mSourceList.empty() ) {
- return FmErrWrongParam;
- }
-
- emit notifyPreparing( true );
-
- int numofFolders = 0;
- int numofFiles = 0;
-
- int ret = FmFolderDetails::queryDetailOfContentList( mSourceList, numofFolders,
- numofFiles, mTotalSize, mStop, true );
- if( ret != FmErrNone ) {
- return ret;
- }
-
- emit notifyStart( true, mTotalSteps );
-
- foreach( const QString& source, mSourceList ) {
- QFileInfo fi( source );
- if( !fi.exists() ) {
- *mErrString = source;
- ret = FmErrSrcPathDoNotExist;
- return ret;
- }
- QString newName;
- bool isAcceptReplace = false;
- QFileInfo destFi( mTargetPath + fi.fileName() );
-
- // while for duplicated file/dir
- while( destFi.exists() ) {
- if( destFi.isFile() && destFi.absoluteFilePath().compare( fi.absoluteFilePath(), Qt::CaseInsensitive ) != 0 ) {
- emit askForReplace( destFi.absoluteFilePath(), fi.absoluteFilePath(), &isAcceptReplace );
- if( isAcceptReplace ) {
- //delete src file
- if( !QFile::remove( destFi.absoluteFilePath() ) ) {
- *mErrString = destFi.absoluteFilePath();
- ret = FmErrCannotRemove;
- break;
- }
- destFi.setFile( destFi.absoluteFilePath() );
- } else {
- queryForRename( destFi.absoluteFilePath(), &newName );
- if( newName.isEmpty() ) {
- ret = FmErrCancel;
- break;
- }
- QString targetName = mTargetPath + newName;
- destFi.setFile( targetName );
- }
- } else{
- // destination is dir
- queryForRename( destFi.absoluteFilePath(), &newName );
- if( newName.isEmpty() ) {
- ret = FmErrCancel;
- break;
- }
- QString targetName = mTargetPath + newName;
- destFi.setFile( targetName );
- }
- }
- if( ret != FmErrNone ) {
- return ret;
- }
- ret = copy( source, mTargetPath, newName );
- if( ret != FmErrNone ) {
- return ret;
- }
- }
- return FmErrNone;
-}
-
-
-
-int FmOperationCopy::copy( const QString &source, const QString &targetPath,
- const QString &newTargetName )
-{
- if( *mStop ) {
- return FmErrCancel;
- }
-
- QFileInfo fi( source );
- if( !fi.exists() ) {
- *mErrString = source;
- return FmErrSrcPathDoNotExist;
- }
- QString newName;
- if( !newTargetName.isEmpty() ) {
- newName = targetPath + newTargetName;
- } else {
- newName = targetPath + fi.fileName();
- }
-
- int ret = FmErrNone;
-
- if (fi.isFile()) {
- quint64 fileSize = fi.size();
- if ( !QFile::copy( source, newName )) {
- *mErrString = source;
- ret = FmErrCannotCopy;
- } else {
- increaseProgress( fileSize );
- }
- } else if (fi.isDir()) {
- ret = copyDirInsideContent( source, newName );
- } else {
- qWarning( "Things other than file and directory are not copied" );
- ret = FmErrIsNotFileOrFolder;
- }
-
- return ret;
-}
-
-
-
-int FmOperationCopy::copyDirInsideContent( const QString &srcPath, const QString &destPath )
-{
- QFileInfo srcInfo( srcPath );
- QFileInfo destInfo( destPath );
-
- QString destUpPath = FmUtils::fillPathWithSplash( destInfo.absolutePath() );
- if( destUpPath.contains( srcPath, Qt::CaseInsensitive ) ) {
- *mErrString = destPath;
- return FmErrCopyDestToSubFolderInSrc;
- }
-
-
- if( !srcInfo.isDir() || !srcInfo.exists() ) {
- *mErrString = srcPath;
- return FmErrSrcPathDoNotExist;
- }
-
- if( !destInfo.exists() ) {
- if( !destInfo.dir().mkdir( destInfo.absoluteFilePath() ) ) {
- *mErrString = destPath;
- return FmErrCannotMakeDir;
- }
- }
-
- if( !srcInfo.isDir() ) {
- *mErrString = destPath;
- return FmErrCannotMakeDir;
- }
-
- //start to copy
- QFileInfoList infoList = QDir( srcPath ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System );
- while( !infoList.isEmpty() ) {
- if( *mStop ) {
- return FmErrCancel;
- }
-
- QFileInfo fileInfo = infoList.takeFirst();
- if( fileInfo.isFile() ){
- //copy file
- QString newFilePath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() );
- if (!QFile::copy( fileInfo.absoluteFilePath(), newFilePath ) ) {
- *mErrString = fileInfo.absoluteFilePath();
- return FmErrCannotCopy;
- }
- increaseProgress( fileInfo.size() );
- } else if( fileInfo.isDir() ) {
- //makedir
- QString newDirPath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() );
- if( !QDir( newDirPath ).exists() && !QDir( destPath ).mkdir( newDirPath ) ) {
- *mErrString = newDirPath;
- return FmErrCannotMakeDir;
- }
- // add dir content to list.
- QFileInfoList infoListDir = QDir( fileInfo.absoluteFilePath() ).entryInfoList(
- QDir::NoDotAndDotDot | QDir::AllEntries );
- while( !infoListDir.isEmpty() ) {
- infoList.push_front( infoListDir.takeLast() );
- }
-
- } else {
- *mErrString = fileInfo.absoluteFilePath();
- return FmErrIsNotFileOrFolder;
- }
-
- }
-
- return FmErrNone;
-}
-
-void FmOperationCopy::increaseProgress( quint64 size )
-{
- if( mTotalSize <=0 ) {
- return;
- }
- mCopiedSize += size;
- int step = ( mCopiedSize * 100 ) / mTotalSize;
- if( step > mCurrentStep ) {
- mCurrentStep = step;
- emit notifyProgress( mCurrentStep );
- }
-}
-
-void FmOperationCopy::queryForRename( const QString &srcFile, QString *destFile )
-{
- emit askForRename( srcFile, destFile );
-}
--- a/filemanager/src/filemanager/src/operationservice/fmoperationcopy.h Tue Jul 06 14:06:28 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#ifndef FMOPERATIONCOPY_H
-#define FMOPERATIONCOPY_H
-#include <QObject>
-#include <QString>
-
-#include "fmoperationbase.h"
-
-class FmOperationCopy : public FmOperationBase
-{
-Q_OBJECT
-public:
- explicit FmOperationCopy( QObject *parent, QStringList sourceList, QString targetPath );
- virtual ~FmOperationCopy();
- int start( volatile bool *isStopped, QString *errString );
-
- QStringList sourceList();
- QString targetPath();
-
-signals:
- void askForRename( const QString &srcFile, QString *destFile );
- void askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
- void showNote( const char *note );
- void notifyPreparing( bool cancelable );
- void notifyStart( bool cancelable, int maxSteps );
- void notifyProgress( int currentStep );
-
-private:
- int copy( const QString &source, const QString &targetPath, const QString &newTargetName = QString() );
- int copyDirInsideContent( const QString &srcPath, const QString &destPath );
- void increaseProgress( quint64 size );
- void queryForRename( const QString &srcFile, QString *destFile );
-
-private:
- QStringList mSourceList;
- QString mTargetPath;
-
-private:
- volatile bool *mStop;
- quint64 mTotalSize;
-
- QString *mErrString;
-
- quint64 mCopiedSize;
- int mTotalSteps;
- int mCurrentStep;
-};
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -0,0 +1,426 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "fmoperationcopyormove.h"
+#include "fmcommon.h"
+#include "fmoperationbase.h"
+#include "fmdrivedetailstype.h"
+#include "fmutils.h"
+
+#include <QDir>
+#include <QFileInfo>
+#include <QStringList>
+#include <QStack>
+
+/* \fn void askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted )
+ * This signal is emitted when the same file as \a srcFile exists.
+ * \a destFile the destination file.
+ * \a isAccepted whether to replace the destination file.
+ */
+
+/* \fn void askForRename( const QString &srcFile, QString *destFile )
+ * This signal is emitted when \a srcFile needs to be renamed.
+ * \a destFile return the new name.
+ */
+
+/* \fn void driveSpaceChanged()
+ * This signal is emitted when copy or move is completed, and used to update the drive size.
+ */
+
+//the size of one time copy
+const int FmOneTimeCopyOrMoveSize = 1024;
+//the total steps of progress bar
+const int FmTotalProgressBarSteps = 100;
+/*
+ * Constructs a copy or move operation with
+ * \a operationService parent
+ * \a type the type of operation(EOperationTypeCopy or EOperationTypeMove)
+ * \a sourceList the source file or path lists that will be copied
+ * \a targetPath the target path where the source file will be copied
+ */
+FmOperationCopyOrMove::FmOperationCopyOrMove( FmOperationService *operationService, FmOperationService::TOperationType type, const QStringList &sourceList, const QString &targetPath )
+ : FmOperationBase( operationService, type ),
+ mOperationService( operationService ), mSourceList( sourceList ), mTargetPath( targetPath ),
+ mStop( 0 ), mTotalSize( 0 ), mCopiedOrMovedSize( 0 ), mTotalSteps( FmTotalProgressBarSteps ), mCurrentStep( 0 )
+{
+ mTargetPath = FmUtils::fillPathWithSplash( mTargetPath );
+ connect( this, SIGNAL( askForRename( QString, QString* ) ),
+ mOperationService, SLOT( on_operation_askForRename( QString, QString* )), Qt::BlockingQueuedConnection );
+ connect( this, SIGNAL( askForReplace( QString, QString, bool* ) ),
+ mOperationService, SLOT( on_operation_askForReplace( QString, QString, bool* )), Qt::BlockingQueuedConnection );
+ connect( this, SIGNAL( driveSpaceChanged() ),
+ mOperationService, SLOT( on_operation_driveSpaceChanged() ) );
+}
+
+/*
+ * Destructs the copy or move operation.
+ */
+FmOperationCopyOrMove::~FmOperationCopyOrMove()
+{
+}
+
+/*
+ * Returns the source file or path list
+ */
+QStringList FmOperationCopyOrMove::sourceList()
+{
+ return mSourceList;
+}
+
+/*
+ * Returns the target path
+ */
+QString FmOperationCopyOrMove::targetPath()
+{
+ return mTargetPath;
+}
+
+/*
+ * Starts the operation.
+ * \a isStopped flag the outside stop operation
+ */
+void FmOperationCopyOrMove::start( volatile bool *isStopped )
+{
+ mStop = isStopped;
+ mTotalSize = 0;
+ mCopiedOrMovedSize = 0;
+ mCurrentStep = 0;
+
+ if( mSourceList.empty() ) {
+ emit notifyError( FmErrWrongParam, mErrString );
+ return ;
+ }
+
+ emit notifyPreparing( true );
+
+ int numofFolders = 0;
+ int numofFiles = 0;
+
+ int ret = FmFolderDetails::queryDetailOfContentList( mSourceList, numofFolders,
+ numofFiles, mTotalSize, mStop, true );
+ if( ret != FmErrNone ) {
+ emit notifyError( ret, mErrString );
+ return;
+ }
+
+ emit notifyStart( true, mTotalSteps );
+
+ foreach( const QString& source, mSourceList ) {
+ // formatPath, but do not append splash in the end
+ // Otherwise could not get fileName in QFileInfo::fileName
+ QString checkedSource( FmUtils::formatPath( source ) );
+ QFileInfo fi( checkedSource );
+ if( !fi.exists() ) {
+ mErrString = checkedSource;
+ emit notifyError( FmErrSrcPathDoNotExist, mErrString );
+ return;
+ }
+ QString newName;
+ bool isAcceptReplace = false;
+ QFileInfo destFi( mTargetPath + fi.fileName() );
+
+ // while for duplicated file/dir
+ while( destFi.exists() ) {
+ if( destFi.isFile() && destFi.absoluteFilePath().compare( fi.absoluteFilePath(), Qt::CaseInsensitive ) != 0 ) {
+ emit askForReplace( destFi.absoluteFilePath(), fi.absoluteFilePath(), &isAcceptReplace );
+ if( isAcceptReplace ) {
+ //delete src file
+ if( !QFile::remove( destFi.absoluteFilePath() ) ) {
+ mErrString = destFi.absoluteFilePath();
+ ret = FmErrCannotRemove;
+ break;
+ }
+ destFi.setFile( destFi.absoluteFilePath() );
+ } else {
+ queryForRename( destFi.absoluteFilePath(), &newName );
+ if( newName.isEmpty() ) {
+ ret = FmErrCancel;
+ break;
+ }
+ QString targetName = mTargetPath + newName;
+ destFi.setFile( targetName );
+ }
+ } else{
+ // destination is dir
+ queryForRename( destFi.absoluteFilePath(), &newName );
+ if( newName.isEmpty() ) {
+ ret = FmErrCancel;
+ break;
+ }
+ QString targetName = mTargetPath + newName;
+ destFi.setFile( targetName );
+ }
+ }
+ if( ret != FmErrNone ) {
+ emit notifyError( ret, mErrString );
+ // 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();
+ return;
+ }
+ ret = copyOrMove( checkedSource, mTargetPath, newName );
+ if( ret != FmErrNone ) {
+ emit notifyError( ret, mErrString );
+ emit driveSpaceChanged();
+ return;
+ }
+ }
+ emit notifyFinish();
+ emit driveSpaceChanged();
+}
+
+/*
+ * Copy or move the \a source to \a targetPath
+ * with \a newTargetName
+ */
+int FmOperationCopyOrMove::copyOrMove( const QString &source, const QString &targetPath,
+ const QString &newTargetName )
+{
+ if( *mStop ) {
+ return FmErrCancel;
+ }
+
+ QFileInfo fi( source );
+ if( !fi.exists() ) {
+ mErrString = source;
+ return FmErrSrcPathDoNotExist;
+ }
+ QString newName;
+ if( !newTargetName.isEmpty() ) {
+ newName = targetPath + newTargetName;
+ } else {
+ newName = targetPath + fi.fileName();
+ }
+
+ int ret = FmErrNone;
+
+ if ( fi.isFile() ) {
+ quint64 fileSize = fi.size();
+ ret = copyOneFile( source, newName );
+ if (ret != FmErrNone) {
+ mErrString = source;
+ return ret;
+ }
+ if ( operationType() == FmOperationService::EOperationTypeMove
+ && !QFile::remove( source ) ) {
+ mErrString = source;
+ return FmErrCannotRemove;
+ }
+ } else if ( fi.isDir() ) {
+ if( operationType() == FmOperationService::EOperationTypeMove
+ && FmUtils::isDefaultFolder( source ) ){
+ ret = FmErrRemoveDefaultFolder;
+ }
+ else{
+ ret = copyOrMoveDirInsideContent( source, newName );
+ }
+ if( ret!= FmErrNone ) {
+ return ret;
+ }
+ if ( operationType() == FmOperationService::EOperationTypeMove
+ && !fi.dir().rmdir( fi.absoluteFilePath() ) ) {
+ mErrString = fi.absolutePath();
+ return FmErrCannotRemove;
+ }
+ } else {
+ qWarning( "Things other than file and directory are not copied" );
+ ret = FmErrIsNotFileOrFolder;
+ }
+
+ return ret;
+}
+
+/*
+ copy \a srcPath as \a destPath
+ both \a srcPath and \a destPath are Directory
+*/
+int FmOperationCopyOrMove::copyOrMoveDirInsideContent( const QString &srcPath, const QString &destPath )
+{
+ QFileInfo srcInfo( srcPath );
+ QFileInfo destInfo( destPath );
+
+ if( FmUtils::isSubLevelPath( srcPath, destPath ) ) {
+ mErrString = destPath;
+ if ( operationType() == FmOperationService::EOperationTypeMove ) {
+ return FmErrMoveDestToSubFolderInSrc;
+ } else {
+ return FmErrCopyDestToSubFolderInSrc;
+ }
+
+ }
+
+ if( !srcInfo.isDir() || !srcInfo.exists() ) {
+ mErrString = srcPath;
+ return FmErrSrcPathDoNotExist;
+ }
+
+ if( !destInfo.exists() ) {
+ if( !destInfo.dir().mkdir( destInfo.absoluteFilePath() ) ) {
+ mErrString = destPath;
+ return FmErrCannotMakeDir;
+ }
+ }
+ destInfo.setFile( destPath );
+ if( !destInfo.isDir() ) {
+ mErrString = destPath;
+ return FmErrCannotMakeDir;
+ }
+
+ //start to copy
+ QFileInfoList infoList = QDir( srcPath ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System );
+ while( !infoList.isEmpty() ) {
+ if( *mStop ) {
+ return FmErrCancel;
+ }
+
+ QFileInfo fileInfo = infoList.takeFirst();
+ if( fileInfo.isFile() ){
+ //copy file
+ QString newFilePath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() );
+ int ret = copyOneFile( fileInfo.absoluteFilePath(), newFilePath );
+ if ( ret != FmErrNone ) {
+ mErrString = fileInfo.absoluteFilePath();
+ return ret;
+ }
+ if( operationType() == FmOperationService::EOperationTypeMove
+ && !QFile::remove( fileInfo.absoluteFilePath() ) ) {
+ mErrString = fileInfo.absoluteFilePath();
+ return FmErrCannotRemove;
+ }
+ } else if( fileInfo.isDir() ) {
+ //makedir
+ QString newDirPath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() );
+ if( !QDir( newDirPath ).exists() && !QDir( destPath ).mkdir( newDirPath ) ) {
+ mErrString = newDirPath;
+ return FmErrCannotMakeDir;
+ }
+ // add dir content to list.
+ QFileInfoList infoListDir = QDir( fileInfo.absoluteFilePath() ).entryInfoList(
+ QDir::NoDotAndDotDot | QDir::AllEntries );
+ if ( operationType() == FmOperationService::EOperationTypeMove ) {
+ if( infoListDir.isEmpty() ) {
+ if ( !fileInfo.dir().rmdir( fileInfo.absoluteFilePath() ) ) {
+ mErrString = fileInfo.absolutePath();
+ return FmErrCannotRemove;
+ }
+ } else {
+ infoList.push_front( fileInfo );
+ }
+ }
+ while( !infoListDir.isEmpty() ) {
+ infoList.push_front( infoListDir.takeLast() );
+ }
+
+ } else {
+ mErrString = fileInfo.absoluteFilePath();
+ return FmErrIsNotFileOrFolder;
+ }
+
+ }
+
+ return FmErrNone;
+}
+
+/*
+ * Increase the progress bar
+ * \a size the current copy or moved size
+ */
+void FmOperationCopyOrMove::increaseProgress( quint64 size )
+{
+ if( mTotalSize <=0 ) {
+ return;
+ }
+ mCopiedOrMovedSize += size;
+ int step = ( mCopiedOrMovedSize * FmTotalProgressBarSteps ) / mTotalSize;
+ if( step > mCurrentStep ) {
+ mCurrentStep = step;
+ emit notifyProgress( mCurrentStep );
+ }
+}
+
+/*
+ * Emits askForRename signal.
+ * \a srcFile the source file path.
+ * \a destFile get the new name from user input
+ */
+void FmOperationCopyOrMove::queryForRename( const QString &srcFile, QString *destFile )
+{
+ emit askForRename( srcFile, destFile );
+}
+
+/*
+ * Copys one file from \a srcFile to \a desFile
+ */
+int FmOperationCopyOrMove::copyOneFile( const QString &srcFile, const QString &desFile )
+{
+ QFile src( srcFile );
+ QFile des( desFile );
+ if ( !src.open( QIODevice::ReadOnly ) || !des.open( QIODevice::WriteOnly ) ) {
+ return FmErrCannotCopy;
+ }
+ QDataStream outputStream( &src );
+ QDataStream inputStream( &des );
+ //used to cache data from source file to target file during one copy
+ QScopedPointer<char> tempString( new char[FmOneTimeCopyOrMoveSize] );
+ memset( tempString.data(), 0, FmOneTimeCopyOrMoveSize );
+ while ( !outputStream.atEnd() ) {
+ if ( *mStop ) {
+ src.close();
+ des.close();
+ QFile::remove( desFile );
+ return FmErrCancel;
+ }
+ int ret = outputStream.readRawData(tempString.data(), FmOneTimeCopyOrMoveSize );
+ if (ret == -1) {
+ src.close();
+ des.close();
+ QFile::remove( desFile );
+ return FmErrCannotCopy;
+ }
+ ret = inputStream.writeRawData(tempString.data(), ret);
+ if (ret == -1) {
+ src.close();
+ des.close();
+ QFile::remove( desFile );
+ return FmErrCannotCopy;
+ }
+ memset( tempString.data(), 0, FmOneTimeCopyOrMoveSize );
+ increaseProgress( ret );
+ }
+ src.close();
+ des.close();
+ if ( FmUtils::setFileAttributes( srcFile, desFile ) != FmErrNone ) {
+ QFile::remove( desFile );
+ return FmErrCannotCopy;
+ }
+ return FmErrNone;
+}
+
+/*
+ * Prepare some work before starting operation.
+ * Returns error number.
+ */
+int FmOperationCopyOrMove::prepare()
+{
+ if( mSourceList.empty() ) {
+ return FmErrWrongParam;
+ } else {
+ return FmErrNone;
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationcopyormove.h Wed Aug 18 09:39:39 2010 +0300
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef FMOPERATIONCOPYORMOVE_H
+#define FMOPERATIONCOPYORMOVE_H
+
+#include <QObject>
+#include <QString>
+
+#include "fmoperationbase.h"
+
+class FmOperationCopyOrMove : public FmOperationBase
+{
+ Q_OBJECT
+
+public:
+ explicit FmOperationCopyOrMove( FmOperationService *operationService, FmOperationService::TOperationType type, const QStringList &sourceList, const QString &targetPath );
+ virtual ~FmOperationCopyOrMove();
+ virtual int prepare();
+ virtual void start( volatile bool *isStopped );
+ QStringList sourceList();
+ QString targetPath();
+
+signals:
+ void askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
+ void askForRename( const QString &srcFile, QString *destFile );
+ void driveSpaceChanged();
+
+private:
+ int copyOrMove( const QString &source, const QString &targetPath, const QString &newTargetName = QString() );
+ int copyOrMoveDirInsideContent( const QString &srcPath, const QString &destPath );
+ void increaseProgress( quint64 size );
+ void queryForRename( const QString &srcFile, QString *destFile );
+ int copyOneFile( const QString &srcFile, const QString &desFile );
+
+private:
+ FmOperationService *mOperationService;
+ QStringList mSourceList;
+ QString mTargetPath;
+ volatile bool *mStop;
+ QString mErrString;
+
+ quint64 mTotalSize;
+ quint64 mCopiedOrMovedSize;
+ int mTotalSteps;
+ int mCurrentStep;
+};
+#endif
--- a/filemanager/src/filemanager/src/operationservice/fmoperationformat.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat.h Wed Aug 18 09:39:39 2010 +0300
@@ -28,16 +28,13 @@
{
Q_OBJECT
public:
- explicit FmOperationFormat( QObject *parent, QString mDriverName );
+ explicit FmOperationFormat( QObject *parent, const QString &mDriverName );
virtual ~FmOperationFormat();
- QString driverName();
+ QString driverName();
+ virtual void start( volatile bool *isStopped );
- int start();
-
signals:
- void notifyStart( bool cancelable, int maxSteps );
- void notifyProgress( int currentStep );
- void notifyPreparing( bool cancelable );
+ void driveSpaceChanged();
private:
QString mDriverName;
--- a/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat_s60.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -26,28 +26,50 @@
#include <e32property.h>
#include <coreapplicationuisdomainpskeys.h>
-FmOperationFormat::FmOperationFormat( QObject *parent, QString mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ),
+/* \fn void driveSpaceChanged()
+ * This signal is emitted when copy or move is completed, and used to update the drive size.
+ */
+
+/*
+ * Constructs a format operation with \a parent
+ * \a mDriverName the drive to be formatted.
+ */
+FmOperationFormat::FmOperationFormat( QObject *parent, const QString &mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ),
mDriverName( mDriverName )
{
+ connect( this, SIGNAL( driveSpaceChanged() ),
+ parent, SLOT( on_operation_driveSpaceChanged() ) );
}
+
+/*
+ * Destructs the operation.
+ */
FmOperationFormat::~FmOperationFormat()
{
}
+/*
+ * Returns the to be formatted drive name
+ */
QString FmOperationFormat::driverName()
{
return mDriverName;
}
-int FmOperationFormat::start()
+/*
+ * Starts to format.
+ * \a isStopped not used
+ */
+void FmOperationFormat::start( volatile bool */*isStopped*/ )
{
QString logString = "FmOperationFormat::start";
- FmLogger::log( logString );
+ FM_LOG( logString );
emit notifyPreparing( false );
if( mDriverName.isEmpty() ) {
- return FmErrWrongParam;
+ emit notifyError( FmErrWrongParam, QString() );
+ return;
}
RFormat format;
@@ -56,7 +78,8 @@
int err = fs.Connect();
if( err != KErrNone ){
- return FmErrTypeFormatFailed;
+ emit notifyError( FmErrTypeFormatFailed, QString() );
+ return;
}
TInt drive = 0;
@@ -73,19 +96,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 +116,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 +133,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 +149,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 +160,7 @@
ECoreAppUIsEjectCommandUsed );
logString = "Prevent SysAp shutting down applications" ;
- FmLogger::log( logString );
+ FM_LOG( logString );
}
else
{
@@ -146,7 +169,7 @@
err = KErrCancel;
logString = QString( "Format cancel" );
- FmLogger::log( logString );
+ FM_LOG( logString );
}
}
@@ -154,17 +177,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 );
}
}
@@ -177,9 +200,14 @@
}
if( err == KErrNone ){
- return FmErrNone;
+ emit notifyFinish();
}
else{
- return FmErrTypeFormatFailed;
+ emit notifyError( FmErrTypeFormatFailed, 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();
+
}
--- a/filemanager/src/filemanager/src/operationservice/fmoperationformat_win.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationformat_win.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -22,26 +22,46 @@
#include <QString>
-FmOperationFormat::FmOperationFormat( QObject *parent, QString mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ),
+/* \fn void driveSpaceChanged()
+ * This signal is emitted when copy or move is completed, and used to update the drive size.
+ */
+
+/*
+ * Constructs a format operation with \a parent
+ * \a mDriverName the drive to be formatted.
+ */
+FmOperationFormat::FmOperationFormat( QObject *parent, const QString &mDriverName ) : FmOperationBase( parent, FmOperationService::EOperationTypeFormat ),
mDriverName( mDriverName )
{
}
+
+/*
+ * Destructs the operation.
+ */
FmOperationFormat::~FmOperationFormat()
{
}
+/*
+ * Returns the to be formatted drive name
+ */
QString FmOperationFormat::driverName()
{
return mDriverName;
}
-int FmOperationFormat::start()
+/*
+ * Starts to format.
+ * \a isStopped not used
+ */
+void FmOperationFormat::start( volatile bool */*isStopped*/ );
{
QString logString = "FmOperationFormat::start";
- FmLogger::log( logString );
+ FM_LOG( logString );
if( mDriverName.isEmpty() ) {
- return FmErrWrongParam;
+ emit notifyError( FmErrWrongParam );
+ return;
}
int totalCount( 100 );
emit notifyStart( totalCount, false );
@@ -49,6 +69,7 @@
emit notifyProgress( i );
}
- return FmErrNone;
+ emit notifyFinish();
+ emit driveSpaceChanged();
}
--- a/filemanager/src/filemanager/src/operationservice/fmoperationmove.cpp Tue Jul 06 14:06:28 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,277 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#include "fmoperationmove.h"
-#include "fmcommon.h"
-#include "fmoperationbase.h"
-#include "fmdrivedetailstype.h"
-#include "fmutils.h"
-
-#include <QDir>
-#include <QFileInfo>
-#include <QStringList>
-#include <QStack>
-
-FmOperationMove::FmOperationMove( QObject *parent, QStringList sourceList, QString targetPath ) :
- FmOperationBase( parent, FmOperationService::EOperationTypeMove ),
- mSourceList( sourceList ), mTargetPath( targetPath ),
- mStop( 0 ), mTotalSize( 0 ), mErrString( 0 ), mMovedSize( 0 ), mTotalSteps( 100 ), mCurrentStep( 0 )
-{
-}
-
-FmOperationMove::~FmOperationMove()
-{
-}
-
-QStringList FmOperationMove::sourceList()
-{
- return mSourceList;
-}
-QString FmOperationMove::targetPath()
-{
- return mTargetPath;
-}
-
-int FmOperationMove::start( volatile bool *isStopped, QString *errString )
-{
- mStop = isStopped;
- mErrString = errString;
-
- mTotalSize = 0;
- mMovedSize = 0;
- mCurrentStep = 0;
-
-
- if( mSourceList.empty() ) {
- return FmErrWrongParam;
- }
-
- emit notifyPreparing( true );
-
- int numofFolders = 0;
- int numofFiles = 0;
-
- int ret = FmFolderDetails::queryDetailOfContentList( mSourceList, numofFolders,
- numofFiles, mTotalSize, mStop, true );
- if( ret != FmErrNone ) {
- return ret;
- }
-
- emit notifyStart( true, mTotalSteps );
- foreach( const QString& source, mSourceList ) {
- QFileInfo fi( source );
- if( !fi.exists() ) {
- *mErrString = source;
- ret = FmErrSrcPathDoNotExist;
- return ret;
- }
- QString newName;
- bool isAcceptReplace = false;
- QFileInfo destFi( mTargetPath + fi.fileName() );
- // while for duplicated file/dir
- while( destFi.exists() ) {
- if( destFi.isFile() && destFi.absoluteFilePath().compare( fi.absoluteFilePath(), Qt::CaseInsensitive ) != 0 ) {
- emit askForReplace( destFi.absoluteFilePath(), fi.absoluteFilePath(), &isAcceptReplace );
- if( isAcceptReplace ) {
- //delete src file
- if( !QFile::remove( destFi.absoluteFilePath() ) ) {
- *mErrString = destFi.absoluteFilePath();
- ret = FmErrCannotRemove;
- break;
- }
- destFi.setFile( destFi.absoluteFilePath() );
- } else {
- queryForRename( destFi.absoluteFilePath(), &newName );
- if( newName.isEmpty() ) {
- ret = FmErrCancel;
- break;
- }
- QString targetName = mTargetPath + newName;
- destFi.setFile( targetName );
- }
- } else{
- // destination is dir
- queryForRename( destFi.absoluteFilePath(), &newName );
- if( newName.isEmpty() ) {
- ret = FmErrCancel;
- break;
- }
- QString targetName = mTargetPath + newName;
- destFi.setFile( targetName );
- }
- }
- if( ret != FmErrNone ) {
- return ret;
- }
-
- int ret = move( source, mTargetPath, newName );
- if( ret != FmErrNone ) {
- return ret;
- }
- }
- return FmErrNone;
-}
-
-int FmOperationMove::move( const QString &source, const QString &targetPath, const QString &newTargetName )
-{
- if( *mStop ) {
- return FmErrCancel;
- }
-
- QFileInfo fi( source );
- if( !fi.exists() ) {
- *mErrString = source;
- return FmErrSrcPathDoNotExist;
- }
- QString newName;
- if( !newTargetName.isEmpty() ) {
- newName = targetPath + newTargetName;
- } else {
- newName = targetPath + fi.fileName();
- }
-
- int ret = FmErrNone;
- if (fi.isFile()) {
- int fileSize = fi.size();
- if ( !QFile::copy( source, newName )) {
- *mErrString = source;
- ret = FmErrCannotCopy;
- }
- if( !QFile::remove( source ) ) {
- *mErrString = source;
- ret = FmErrCannotRemove;
- }
- increaseProgress( fileSize );
- } else if (fi.isDir()) {
- if( FmUtils::isDefaultFolder( source ) ){
- ret = FmErrRemoveDefaultFolder;
- }
- else{
- ret = moveDirInsideContent( source, newName );
- }
-
- if( ret!= FmErrNone ) {
- return ret;
- }
- if ( !fi.dir().rmdir( fi.absoluteFilePath() ) ) {
- *mErrString = fi.absolutePath();
- return FmErrCannotRemove;
- }
- } else {
- qWarning( "Things other than file and directory are not copied" );
- ret = FmErrIsNotFileOrFolder;
- }
-
- return ret;
-}
-int FmOperationMove::moveDirInsideContent( const QString &srcPath, const QString &destPath )
-{
- QFileInfo srcInfo( srcPath );
- QFileInfo destInfo( destPath );
-
- QString destUpPath = FmUtils::fillPathWithSplash( destInfo.absolutePath() );
- if( destUpPath.contains( srcPath, Qt::CaseInsensitive ) ) {
- *mErrString = destPath;
- return FmErrMoveDestToSubFolderInSrc;
- }
-
- if( !srcInfo.isDir() || !srcInfo.exists() ) {
- *mErrString = srcPath;
- return FmErrSrcPathDoNotExist;
- }
-
- if( !destInfo.exists() ) {
- if( !destInfo.dir().mkdir( destInfo.absoluteFilePath() ) ) {
- *mErrString = destPath;
- return FmErrCannotMakeDir;
- }
- }
- if( !srcInfo.isDir() ) {
- *mErrString = destPath;
- return FmErrCannotMakeDir;
- }
-
- //start to move
- QFileInfoList infoList = QDir( srcPath ).entryInfoList( QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System );
- while( !infoList.isEmpty() ) {
- if( *mStop ) {
- return FmErrCancel;
- }
-
- QFileInfo fileInfo = infoList.takeFirst();
- if( fileInfo.isFile() ){
- //copy file
- quint64 fileSize = fileInfo.size();
- QString newFilePath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() );
- if (!QFile::copy( fileInfo.absoluteFilePath(), newFilePath ) ) {
- *mErrString = fileInfo.absoluteFilePath();
- return FmErrCannotCopy;
- }
- if( !QFile::remove( fileInfo.absoluteFilePath() ) ) {
- *mErrString = fileInfo.absoluteFilePath();
- return FmErrCannotRemove;
- }
- increaseProgress( fileSize );
- } else if( fileInfo.isDir() ) {
- //makedir
- QString newDirPath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() );
- if( !QDir( newDirPath ).exists() && !QDir( destPath ).mkdir( newDirPath ) ) {
- *mErrString = newDirPath;
- return FmErrCannotMakeDir;
- }
- // add dir content to list.
- QFileInfoList infoListDir = QDir( fileInfo.absoluteFilePath() ).entryInfoList(
- QDir::NoDotAndDotDot | QDir::AllEntries );
- if( infoListDir.isEmpty() ) {
- if ( !fileInfo.dir().rmdir( fileInfo.absoluteFilePath() ) ) {
- *mErrString = fileInfo.absolutePath();
- return FmErrCannotRemove;
- }
- } else {
- infoList.push_front( fileInfo );
- }
- while( !infoListDir.isEmpty() ) {
- infoList.push_front( infoListDir.takeLast() );
- }
-
- } else {
- *mErrString = fileInfo.absoluteFilePath();
- return FmErrIsNotFileOrFolder;
- }
-
- }
-
- return FmErrNone;
-}
-
-void FmOperationMove::increaseProgress( quint64 size )
-{
- if( mTotalSize <=0 ) {
- return;
- }
- mMovedSize += size;
- int step = ( mMovedSize * 100 ) / mTotalSize;
- if( step > mCurrentStep ) {
- mCurrentStep = step;
- emit notifyProgress( mCurrentStep );
- }
-}
-
-void FmOperationMove::queryForRename( const QString &srcFile, QString *destFile )
-{
- emit askForRename( srcFile, destFile );
-}
--- a/filemanager/src/filemanager/src/operationservice/fmoperationmove.h Tue Jul 06 14:06:28 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-#ifndef FMOPERATIONMOVE_H
-#define FMOPERATIONMOVE_H
-#include <QObject>
-#include <QString>
-
-#include "fmoperationbase.h"
-
-class FmOperationMove : public FmOperationBase
-{
-Q_OBJECT
-public:
- explicit FmOperationMove( QObject *parent, QStringList sourceList, QString targetPath );
- virtual ~FmOperationMove();
- QStringList sourceList();
- QString targetPath();
- int start( volatile bool *isStopped, QString *errString );
-
-signals:
- void askForRename( const QString &srcFile, QString *destFile );
- void askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
- void showNote( const QString ¬eString );
- void notifyPreparing( bool cancelable );
- void notifyStart( bool cancelable, int maxSteps );
- void notifyProgress( int currentStep );
-
-private:
- int move( const QString &source, const QString &targetPath, const QString &newTargetName = QString() );
- int moveDirInsideContent( const QString &srcPath, const QString &destPath );
- void increaseProgress( quint64 size );
- void queryForRename( const QString &srcFile, QString *destFile );
-
-private:
- QStringList mSourceList;
- QString mTargetPath;
-
-private:
- volatile bool *mStop;
- quint64 mTotalSize;
- QString *mErrString;
-
- quint64 mMovedSize;
- int mTotalSteps;
- int mCurrentStep;
-};
-
-#endif
--- a/filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationremove.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -26,33 +26,54 @@
#include <QStringList>
#include <QStack>
-FmOperationRemove::FmOperationRemove( QObject *parent, QStringList pathList ) :
- FmOperationBase( parent, FmOperationService::EOperationTypeRemove ),
- mPathList( pathList ), mStop( 0 ), mTotalCount( 0 ),
- mErrString( 0 ), mRemovedCount( 0 ), mTotalSteps( 100 ), mCurrentStep( 0 )
+/* \fn void driveSpaceChanged()
+ * This signal is emitted when copy or move is completed, and used to update the drive size.
+ */
+
+/*
+ * Constructs a remove operation with
+ * \a parent parent
+ * \a pathList the file or path to be removed.
+ */
+FmOperationRemove::FmOperationRemove(QObject *parent, const QStringList &pathList ) :
+ FmOperationBase( parent, FmOperationService::EOperationTypeRemove ),
+ mPathList( pathList ),
+ mStop( 0 ),
+ mTotalCount( 0 ), mRemovedCount( 0 ), mTotalSteps( 100 ), mCurrentStep( 0 )
{
+ connect( this, SIGNAL( driveSpaceChanged() ),
+ parent, SLOT( on_operation_driveSpaceChanged() ) );
}
+/*
+ * Destructs the operation.
+ */
FmOperationRemove::~FmOperationRemove()
{
}
+/*
+ * Returns the path list
+ */
QStringList FmOperationRemove::pathList()
{
return mPathList;
}
-int FmOperationRemove::start( volatile bool *isStopped, QString *errString )
+/*
+ * Starts the operation.
+ * \a isStopped flag the outside stop operation
+ */
+void FmOperationRemove::start( volatile bool *isStopped )
{
mStop = isStopped;
- mErrString = errString;
-
mTotalCount = 0;
mRemovedCount = 0;
mCurrentStep = 0;
if( mPathList.empty() ) {
- return FmErrWrongParam;
+ emit notifyError( FmErrWrongParam, mErrString );
+ return ;
}
emit notifyPreparing( true );
@@ -64,7 +85,8 @@
int ret = FmFolderDetails::queryDetailOfContentList( mPathList, numofFolders,
numofFiles, totalSize, mStop, true );
if( ret != FmErrNone ) {
- return ret;
+ emit notifyError( ret, mErrString );
+ return;
}
mTotalCount = numofFolders + numofFiles;
@@ -73,12 +95,21 @@
foreach( const QString& srcPath, mPathList ) {
int ret = remove( srcPath );
if( ret != FmErrNone ) {
- return ret;
+ emit notifyError( ret, mErrString );
+ // 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();
+ return;
}
}
- return FmErrNone;
+ emit notifyFinish();
+ emit driveSpaceChanged();
}
+/*
+ * Removes the file or dir with name \a fileName
+ */
int FmOperationRemove::remove( const QString &fileName )
{
if( *mStop ) {
@@ -89,7 +120,7 @@
QFileInfo fi( fileName );
if (fi.isFile()) {
if( !QFile::remove( fileName ) ) {
- *mErrString = fileName;
+ mErrString = fileName;
ret = FmErrCannotRemove;
}
IncreaseProgressOnce();
@@ -109,6 +140,9 @@
return ret;
}
+/*
+ * Remove the dir with name \a pathName
+ */
int FmOperationRemove::recursiveRemoveDir( const QString &pathName )
{
QFileInfo fi( pathName );
@@ -123,7 +157,7 @@
if (infoList.size() == 0) {
QDir dirToRemove( dirs.pop() );
if ( !dirToRemove.rmdir( dirToRemove.absolutePath() ) ) {
- *mErrString = dirToRemove.absolutePath();
+ mErrString = dirToRemove.absolutePath();
return FmErrCannotRemove;
}
IncreaseProgressOnce();
@@ -139,7 +173,7 @@
dirList.push_front( QDir( it->absoluteFilePath() ) );
} else {
if ( !QFile::remove( it->absoluteFilePath() ) ) {
- *mErrString = it->absoluteFilePath();
+ mErrString = it->absoluteFilePath();
return FmErrCannotRemove;
}
IncreaseProgressOnce();
@@ -153,6 +187,9 @@
return FmErrNone;
}
+/*
+ * Increase the progress bar
+ */
void FmOperationRemove::IncreaseProgressOnce()
{
if( mTotalCount <= 0 )
--- a/filemanager/src/filemanager/src/operationservice/fmoperationremove.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationremove.h Wed Aug 18 09:39:39 2010 +0300
@@ -23,21 +23,18 @@
class FmOperationRemove : public FmOperationBase
{
-Q_OBJECT
+ Q_OBJECT
+
public:
- explicit FmOperationRemove( QObject *parent, QStringList pathList );
+ explicit FmOperationRemove( QObject *parent, const QStringList &pathList );
virtual ~FmOperationRemove();
QStringList pathList();
- int start( volatile bool *isStopped, QString *errString );
-
+ void start( volatile bool *isStopped );
+
signals:
- void askForRename( const QString &srcFile, QString &destFile );
-
- void notifyPreparing( bool cancelable );
- void notifyStart( bool cancelable, int maxSteps );
- void notifyProgress( int currentStep );
-
+ void driveSpaceChanged();
+
private:
int remove( const QString &fileName );
int recursiveRemoveDir( const QString &path );
@@ -46,15 +43,13 @@
private:
QStringList mPathList;
-private:
- volatile bool *mStop;
- quint64 mTotalCount;
+ volatile bool *mStop;
+ QString mErrString;
- QString *mErrString;
-
- quint64 mRemovedCount;
- int mTotalSteps;
- int mCurrentStep;
+ quint64 mTotalCount;
+ quint64 mRemovedCount;
+ int mTotalSteps;
+ int mCurrentStep;
};
#endif
--- a/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -18,6 +18,7 @@
#include "fmoperationbase.h"
#include "fmoperationservice.h"
#include "fmoperationformat.h"
+#include "fmoperationviewdetails.h"
#include "fmviewdetailsdialog.h"
#include "fmdlgutils.h"
#include "fmutils.h"
@@ -27,15 +28,25 @@
#include <hbglobal.h>
#include <QFileInfo>
+/*
+ * Constructs one operation result processer with \a operation Service.
+ */
FmOperationResultProcesser::FmOperationResultProcesser( FmOperationService *operationService )
: mOperationService( operationService ), mNote( 0 )
{
}
+/*
+ * Destructs the operation result processer
+ */
FmOperationResultProcesser::~FmOperationResultProcesser(void)
{
}
+/*
+ * Called by operation service on_operation_askForRename
+ * \sa FmOperationService::on_operation_askForRename
+ */
void FmOperationResultProcesser::onAskForRename(
FmOperationBase* operationBase, const QString &srcFile, QString *destFile )
{
@@ -45,28 +56,42 @@
QString questionText = QString( "file " ) +
srcFile + QString( " already exist, please rename:" );
QString value;
- QFileInfo fileInfo(srcFile);
- bool ret = FmDlgUtils::showTextQuery( questionText, value, true, maxFileNameLength, QString(), false );
+ QFileInfo srcFileInfo(srcFile);
+ QStringList regExpList = (QStringList() << Regex_ValidFileFolderName << Regex_ValidNotEndWithDot );
+
+ bool ret = FmDlgUtils::showTextQuery( questionText, value, regExpList,
+ maxFileNameLength, QString(), false );
while ( ret ) {
// 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( newTargetPath, errString ) ) {
+ if( !FmUtils::checkNewFolderOrFile( value, newTargetPath, errString ) ) {
FmDlgUtils::information( errString );
- ret = FmDlgUtils::showTextQuery( questionText, value, true, maxFileNameLength, QString(), false );
+ ret = FmDlgUtils::showTextQuery( questionText, value, regExpList, maxFileNameLength, QString(), false );
continue;
} else {
break;
}
}
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" ) );
+ }
}
}
+/*
+ * Called by operation service on_operation_askForReplace
+ * \sa FmOperationService::on_operation_askForReplace
+ */
void FmOperationResultProcesser::onAskForReplace(
FmOperationBase* operationBase, const QString &srcFile, const QString &destFile, bool *isAccepted )
{
@@ -82,11 +107,20 @@
}
}
+/*
+ * Called by operation service on_operation_showNote
+ * \sa FmOperationService::on_operation_showNote
+ */
void FmOperationResultProcesser::onShowNote( FmOperationBase* operationBase, const char *noteString )
{
+ Q_UNUSED( operationBase );
FmDlgUtils::information(hbTrId(noteString));
}
+/*
+ * Called by operation service on_operation_notifyWaiting
+ * \sa FmOperationService::on_operation_notifyWaiting
+ */
void FmOperationResultProcesser::onNotifyWaiting( FmOperationBase* operationBase, bool cancelable )
{
QString title = hbTrId("Operation");
@@ -112,6 +146,10 @@
showWaiting( title, cancelable );
}
+/*
+ * Called by operation service on_operation_notifyPreparing
+ * \sa FmOperationService::on_operation_notifyPreparing
+ */
void FmOperationResultProcesser::onNotifyPreparing( FmOperationBase* operationBase, bool cancelable )
{
QString title = hbTrId("Operation");
@@ -142,6 +180,10 @@
showPreparing( title, cancelable );
}
+/*
+ * Called by operation service on_operation_notifyStart
+ * \sa FmOperationService::on_operation_notifyStart
+ */
void FmOperationResultProcesser::onNotifyStart( FmOperationBase* operationBase, bool cancelable, int maxSteps )
{
QString title = hbTrId("Operation");
@@ -172,12 +214,20 @@
showProgress( title, cancelable, maxSteps );
}
+/*
+ * Called by operation service on_operation_notifyProgress
+ * \sa FmOperationService::on_operation_notifyProgress
+ */
void FmOperationResultProcesser::onNotifyProgress( FmOperationBase* operationBase, int currentStep )
{
Q_UNUSED( operationBase );
setProgress( currentStep );
}
+/*
+ * Called by operation service on_operation_notifyFinish
+ * \sa FmOperationService::on_operation_notifyFinish
+ */
void FmOperationResultProcesser::onNotifyFinish( FmOperationBase* operationBase )
{
@@ -210,15 +260,21 @@
QString driveName( paramFormat->driverName() );
FmDriverInfo driverInfo = FmUtils::queryDriverInfo( driveName );
FmDriverInfo::DriveState state = driverInfo.driveState();
+ FmDriverInfo::DriveType driveType = driverInfo.driveType();
+
+ // If drive is available and it is mmc or usb memory
if( ( state & FmDriverInfo::EDriveAvailable ) &&
- ( state & FmDriverInfo::EDriveRemovable ) &&
- !( state & FmDriverInfo::EDriveMassStorage ) ) {
- QString volumeName;
- while( FmDlgUtils::showTextQuery( title, volumeName, false, FmMaxLengthofDriveName ) ){
+ ( driveType == FmDriverInfo::EDriveTypeMemoryCard ||
+ driveType == FmDriverInfo::EDriveTypeUsbMemory ) ) {
+ bool needToSetVolume = false;
+ QString volumeName = FmUtils::getVolumeNameWithDefaultNameIfNull( driveName, needToSetVolume );
+ //use isReturnFalseWhenNoTextChanged = false in order that FmUtils::renameDrive( driveName, volumeName ) will
+ //be excuted at lease once to set the volume name.
+ while( FmDlgUtils::showTextQuery( title, volumeName, QStringList(), FmMaxLengthofDriveName, QString(), false ) ){
int err = FmUtils::renameDrive( driveName, volumeName );
- if ( err == FmErrNone ){
+ if ( err == FmErrNone ) {
FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
- mOperationService->on_operationThread_refreshModel( driveName );
+ mOperationService->on_operation_driveSpaceChanged();
break;
} else if( err == FmErrBadName ) {
FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) );
@@ -245,12 +301,21 @@
}
}
-void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, QString errString )
+
+/*
+ * Called by operation service on_operation_notifyError
+ * \sa FmOperationService::on_operation_notifyError
+ */
+void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, const QString &errString )
{
Q_UNUSED( errString );
failAndCloseProgress();
switch( error )
{
+ case FmErrCancel:
+ cancelProgress();
+ FmDlgUtils::information( QString( hbTrId("Operation Canceled!") ) );
+ return;
case FmErrAlreadyStarted:
FmDlgUtils::information( QString( hbTrId("Operation already started!")) );
return;
@@ -318,21 +383,20 @@
}
-void FmOperationResultProcesser::onNotifyCanceled( FmOperationBase* operationBase )
-{
- Q_UNUSED( operationBase );
- cancelProgress();
- FmDlgUtils::information( QString( hbTrId("Operation Canceled!") ) );
-}
-
-
+/*
+ * Responds to waiting note's cancel signal.
+ */
void FmOperationResultProcesser::onProgressCancelled()
{
mOperationService->cancelOperation();
}
-//
+/*
+ * Shows the waiting dialog with
+ * \a title the title of the dialog.
+ * \a cancelable whether it could be cancelled.
+ */
void FmOperationResultProcesser::showWaiting( QString title, bool cancelable )
{
qDebug("show warning");
@@ -363,6 +427,11 @@
}
+/*
+ * Shows the preparing dialog with
+ * \a title the title of the dialog.
+ * \a cancelable whether it could be cancelled.
+ */
void FmOperationResultProcesser::showPreparing( QString title, bool cancelable )
{
qDebug("show preparing");
@@ -396,6 +465,11 @@
mNote->open();
}
+/*
+ * Shows the progress dialog with
+ * \a title the title of the dialog.
+ * \a cancelable whether it could be cancelled.
+ */
void FmOperationResultProcesser::showProgress( QString title, bool cancelable, int maxValue )
{
qDebug("show progress");
@@ -431,12 +505,19 @@
mNote->open();
}
+/*
+ * Sets the current progress value to be \a value
+ */
void FmOperationResultProcesser::setProgress( int value )
{
qDebug("set progress");
if( mNote )
mNote->setProgressValue( value );
}
+
+/*
+ * Finishes the progress.
+ */
void FmOperationResultProcesser::finishProgress()
{
qDebug("finish progress");
@@ -445,6 +526,9 @@
}
}
+/*
+ * Cancels the progress bar.
+ */
void FmOperationResultProcesser::cancelProgress()
{
qDebug("cancel progress");
@@ -453,6 +537,9 @@
}
}
+/*
+ * Fails and closes the progress bar.
+ */
void FmOperationResultProcesser::failAndCloseProgress()
{
qDebug("fail progress");
--- a/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.h Wed Aug 18 09:39:39 2010 +0300
@@ -41,8 +41,8 @@
void onNotifyFinish( FmOperationBase* operationBase );
- void onNotifyError( FmOperationBase* operationBase, int error, QString errString );
- void onNotifyCanceled( FmOperationBase* operationBase );
+ void onNotifyError( FmOperationBase* operationBase, int error, const QString &errString );
+
private slots:
void onProgressCancelled();
private:
--- a/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -19,17 +19,51 @@
#include "fmoperationservice.h"
#include "fmoperationthread.h"
#include "fmbackupconfigloader.h"
-#include "fmbackuprestorehandler.h"
#include "fmbkupengine.h"
#include "fmviewdetailsdialog.h"
#include "fmoperationresultprocesser.h"
-#include "fmoperationcopy.h"
-#include "fmoperationmove.h"
+#include "fmoperationcopyormove.h"
#include "fmoperationremove.h"
#include "fmoperationformat.h"
-
+#include "fmoperationviewdetails.h"
+#include "fmbackuprestorehandler.h"
#include <hbaction.h>
+/* \fn void driveSpaceChanged( FmOperationBase* operationBase )
+ * This signal is emitted when disk size changed.
+ */
+
+/* \fn void notifyWaiting( FmOperationBase* operationBase, bool cancelable )
+ * This signal is emitted when the operation emits notifyWaiting.
+ */
+
+/* \fn void notifyPreparing( FmOperationBase* operationBase, bool cancelable )
+ * This signal is emitted when the operation emits notifyPreparing.
+ */
+
+/* \fn void notifyStart( FmOperationBase* operationBase, bool cancelable, int maxSteps )
+ * This signal is emitted when the operation emits notifyStart.
+ */
+
+/* \fn void notifyProgress( FmOperationBase* operationBase, int currentStep )
+ * This signal is emitted when the operation emits notifyProgress.
+ */
+
+/* \fn void notifyFinish( FmOperationBase* operationBase )
+ * This signal is emitted when the operation emits notifyFinish.
+ */
+
+/* \fn void notifyError( FmOperationBase* operationBase, int error, QString errString )
+ * This signal is emitted when the operation emits notifyError.
+ */
+
+/* \fn void notifyCanceled( FmOperationBase* operationBase )
+ * This signal is emitted when the operation emits notifyCanceled.
+ */
+
+/*
+ * Constructs one operation Service with \a parent.
+ */
FmOperationService::FmOperationService( QObject *parent ) : QObject( parent ),
mCurrentOperation( 0 )
{
@@ -43,119 +77,127 @@
QMetaObject::connectSlotsByName( this );
}
+/*
+ * Destructs the operation service.
+ */
FmOperationService::~FmOperationService()
{
- delete mThread;
-
+ delete mThread;
delete mBackupRestoreHandler;
-
}
+/*
+ * Returns true if the thread is running, false if not.
+ */
bool FmOperationService::isRunning()
{
- if( mCurrentOperation ) {
- return true;
- } else {
- return false;
- }
-
+ return mThread->isRunning();
}
-int FmOperationService::asyncCopy( QStringList sourceList, QString targetPath )
-{
- if ( isRunning() )
- return FmErrAlreadyStarted;
- Q_ASSERT( !mCurrentOperation );
-
- if( sourceList.empty() ) {
- return FmErrWrongParam;
- }
- mCurrentOperation = new FmOperationCopy( mThread, sourceList, targetPath );
-
- int ret = mThread->asyncCopy( mCurrentOperation );
- if( ret != FmErrNone ) {
+/*
+ * Copys the file or foler \a targetPath asynchronously.
+ */
+int FmOperationService::asyncCopy( const QStringList &sourceList, const QString &targetPath )
+{
+ Q_ASSERT( !mCurrentOperation );
+ mCurrentOperation = new FmOperationCopyOrMove( this, FmOperationService::EOperationTypeCopy, sourceList, targetPath );
+ connectSignalsAndSlots( mCurrentOperation );
+ int ret = mThread->prepareOperationAndStart( mCurrentOperation );
+ if ( ret!= FmErrNone ) {
resetOperation();
- }
- return ret;
+ return ret;
+ }
+ return FmErrNone;
}
-int FmOperationService::asyncMove( QStringList sourceList, QString targetPath )
+/*
+ * Moves the file or foler \a sourceList to \a targetPath asynchronously.
+ */
+int FmOperationService::asyncMove( const QStringList &sourceList, const QString &targetPath )
{
- if ( isRunning() )
- return FmErrAlreadyStarted;
Q_ASSERT( !mCurrentOperation );
- if( sourceList.empty() ) {
- return FmErrWrongParam;
- }
- mCurrentOperation = new FmOperationMove( mThread, sourceList, targetPath );
-
- int ret = mThread->asyncMove( mCurrentOperation );
- if( ret != FmErrNone ) {
+ mCurrentOperation = new FmOperationCopyOrMove( this, FmOperationService::EOperationTypeMove, sourceList, targetPath );
+ connectSignalsAndSlots( mCurrentOperation );
+ int ret = mThread->prepareOperationAndStart( mCurrentOperation );
+ if ( ret!= FmErrNone ) {
resetOperation();
- }
- return ret;
+ return ret;
+ }
+ return FmErrNone;
}
-int FmOperationService::asyncRemove( QStringList pathList )
+/*
+ * Removes the file or dir \a pathList asynchronously.
+ */
+int FmOperationService::asyncRemove( const QStringList &pathList )
{
- if ( isRunning() )
- return FmErrAlreadyStarted;
Q_ASSERT( !mCurrentOperation );
- mCurrentOperation = new FmOperationRemove( mThread, pathList );
-
- int ret = mThread->asyncRemove( mCurrentOperation );
- if( ret != FmErrNone ) {
+ mCurrentOperation = new FmOperationRemove( this, pathList );
+ connectSignalsAndSlots( mCurrentOperation );
+ int ret = mThread->prepareOperationAndStart( mCurrentOperation );
+ if ( ret!= FmErrNone ) {
resetOperation();
- }
- return ret;
+ return ret;
+ }
+ return FmErrNone;
}
-int FmOperationService::asyncFormat( QString driverName )
+/*
+ * Formats the drive \a driverName asynchronously.
+ */
+int FmOperationService::asyncFormat( const QString &driverName )
{
- if ( isRunning() )
- return FmErrAlreadyStarted;
Q_ASSERT( !mCurrentOperation );
- mCurrentOperation = new FmOperationFormat( mThread, driverName );
-
- int ret = mThread->asyncFormat( mCurrentOperation );
- if( ret != FmErrNone ) {
+ mCurrentOperation = new FmOperationFormat( this, driverName );
+ connectSignalsAndSlots( mCurrentOperation );
+ int ret = mThread->prepareOperationAndStart( mCurrentOperation );
+ if ( ret!= FmErrNone ) {
resetOperation();
- }
- return ret;
-}
-int FmOperationService::asyncViewDriveDetails( const QString driverName )
-{
- if ( isRunning() )
- return FmErrAlreadyStarted;
- Q_ASSERT( !mCurrentOperation );
-
- mCurrentOperation = new FmOperationDriveDetails( mThread, driverName );
-
- int ret = mThread->asyncViewDriveDetails( mCurrentOperation );
- if( ret != FmErrNone ) {
- resetOperation();
- }
- return ret;
+ return ret;
+ }
+ return FmErrNone;
}
-int FmOperationService::asyncViewFolderDetails( const QString folderPath )
+/*
+ * Views drive \a driverName details asynchronously.
+ */
+int FmOperationService::asyncViewDriveDetails( const QString &driverName )
{
- if ( isRunning() )
- return FmErrAlreadyStarted;
Q_ASSERT( !mCurrentOperation );
-
- mCurrentOperation = new FmOperationFolderDetails( mThread, folderPath );
-
- int ret = mThread->asyncViewFolderDetails( mCurrentOperation );
- if( ret != FmErrNone ) {
+
+ mCurrentOperation = new FmOperationDriveDetails( this, driverName );
+ connectSignalsAndSlots( mCurrentOperation );
+ int ret = mThread->prepareOperationAndStart( mCurrentOperation );
+ if ( ret!= FmErrNone ) {
resetOperation();
- }
- return ret;
+ return ret;
+ }
+ return FmErrNone;
}
+/*
+ * Views folder \a folderPath details asynchronously.
+ */
+int FmOperationService::asyncViewFolderDetails( const QString &folderPath )
+{
+ Q_ASSERT( !mCurrentOperation );
+
+ mCurrentOperation = new FmOperationFolderDetails( this, folderPath );
+ connectSignalsAndSlots( mCurrentOperation );
+ int ret = mThread->prepareOperationAndStart( mCurrentOperation );
+ if ( ret!= FmErrNone ) {
+ resetOperation();
+ return ret;
+ }
+ return FmErrNone;
+}
+
+/*
+ * Backups asynchronously.
+ */
int FmOperationService::asyncBackup()
{
if ( isRunning() )
@@ -173,6 +215,10 @@
}
}
+/*
+ * Restores asynchronously.
+ * \a selection selected restore items
+ */
int FmOperationService::asyncRestore( quint64 selection )
{
if ( isRunning() )
@@ -190,11 +236,18 @@
}
}
+/*
+ * Delete backup synchronously.
+ * \a selection selected backup items
+ */
int FmOperationService::syncDeleteBackup( quint64 selection )
{
return mBackupRestoreHandler->deleteBackup( selection );
}
+/*
+ * Cancels current operation.
+ */
void FmOperationService::cancelOperation()
{
switch( mCurrentOperation->operationType() )
@@ -225,7 +278,9 @@
}
}
-
+/*
+ * Set valume synchronously. not used.
+ */
int FmOperationService::syncSetVolume( const QString &driverName, const QString &volume )
{
Q_UNUSED( driverName );
@@ -233,6 +288,9 @@
return FmErrNone;
}
+/*
+ * Set drive password synchronously. not used.
+ */
int FmOperationService::syncSetdDriverPassword( const QString &driverName,
const QString &oldPassword,
const QString &newPassword )
@@ -243,6 +301,9 @@
return FmErrNone;
}
+/*
+ * Rename synchronously. not used.
+ */
int FmOperationService::syncRename( const QString &oldPath, const QString &newName )
{
Q_UNUSED( oldPath );
@@ -250,13 +311,17 @@
return FmErrNone;
}
+/*
+ * Launches the file in synchronous way.
+ */
int FmOperationService::syncLaunchFileOpen( const QString &filePath )
{
return FmUtils::launchFile( filePath );
}
-
-
+/*
+ * Returns the backup handler.
+ */
FmBackupRestoreHandler *FmOperationService::backupRestoreHandler()
{
if( !mBackupRestoreHandler ) {
@@ -266,6 +331,9 @@
return mBackupRestoreHandler;
}
+/*
+ * Deletes the operation and set it to be 0.
+ */
void FmOperationService::resetOperation()
{
if( mCurrentOperation ) {
@@ -274,113 +342,201 @@
}
}
-/////////////////////////////////////////////////////
-///Thread
-void FmOperationService::on_operationThread_askForRename( const QString &srcFile, QString *destFile )
+/*
+ * Connects \a operation's sinals to slots
+ */
+void FmOperationService::connectSignalsAndSlots( FmOperationBase *operation )
+{
+
+ connect( operation, SIGNAL( showNote( QString ) ),
+ this, SLOT( on_operation_showNote( QString )), Qt::BlockingQueuedConnection );
+ connect( operation, SIGNAL( notifyError( int, QString ) ),
+ this, SLOT( on_operation_notifyError( int, QString ) ) );
+ connect( operation, SIGNAL( notifyStart( bool, int ) ),
+ this, SLOT( on_operation_notifyStart( bool, int ) ) );
+ connect( operation, SIGNAL( notifyProgress( int ) ),
+ this, SLOT( on_operation_notifyProgress( int ) ) );
+ connect( operation, SIGNAL( notifyFinish() ),
+ this, SLOT( on_operation_notifyFinish()) );
+ connect( operation, SIGNAL( notifyWaiting( bool ) ),
+ this, SLOT( on_operation_notifyWaiting( bool )) );
+
+}
+
+/*
+ * Responds to mCurrentOperation's askForRename signal.
+ * \a srcFile the source file.
+ * \a destFile the new file name.
+ */
+void FmOperationService::on_operation_askForRename( const QString &srcFile, QString *destFile )
{
mOperationResultProcesser->onAskForRename(
mCurrentOperation, srcFile, destFile );
}
-void FmOperationService::on_operationThread_askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted )
+/*
+ * Responds to mCurrentOperation's askForReplace signal.
+ * \a srcFile the source file.
+ * \a destFile the target file.
+ * \a isAccepted whether to replace the target file.
+ */
+void FmOperationService::on_operation_askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted )
{
mOperationResultProcesser->onAskForReplace(
mCurrentOperation, srcFile, destFile, isAccepted );
}
-void FmOperationService::on_operationThread_refreshModel( const QString &path )
-{
- emit refreshModel( mCurrentOperation, path );
-}
-void FmOperationService::on_operationThread_showNote( const char *noteString )
+/*
+ * Responds to mCurrentOperation's showNote signal.
+ * \a noteString the note content.
+ */
+void FmOperationService::on_operation_showNote( const char *noteString )
{
mOperationResultProcesser->onShowNote( mCurrentOperation, noteString );
}
-void FmOperationService::on_operationThread_notifyWaiting( bool cancelable )
+
+/*
+ * Responds to mCurrentOperation's showNote signal.
+ * \a noteString the note content.
+ */
+void FmOperationService::on_operation_notifyWaiting( bool cancelable )
{
mOperationResultProcesser->onNotifyWaiting(
mCurrentOperation, cancelable );
emit notifyWaiting( mCurrentOperation, cancelable );
}
-void FmOperationService::on_operationThread_notifyPreparing( bool cancelable )
+
+/*
+ * Responds to mCurrentOperation's notifyPreparing signal.
+ * \a cancelable indicates whether the progress bar could be cancelled.
+ */
+void FmOperationService::on_operation_notifyPreparing( bool cancelable )
{
mOperationResultProcesser->onNotifyPreparing(
mCurrentOperation, cancelable );
emit notifyPreparing( mCurrentOperation, cancelable );
}
-void FmOperationService::on_operationThread_notifyStart( bool cancelable, int maxSteps )
+
+/*
+ * Responds to mCurrentOperation's notifyPreparing signal.
+ * \a cancelable indicates whether the progress bar could be cancelled.
+ * \maxSteps the length of progress bar.
+ */
+void FmOperationService::on_operation_notifyStart( bool cancelable, int maxSteps )
{
mOperationResultProcesser->onNotifyStart(
mCurrentOperation, cancelable, maxSteps );
emit notifyStart( mCurrentOperation, cancelable, maxSteps );
}
-void FmOperationService::on_operationThread_notifyProgress( int currentStep )
+
+/*
+ * Responds to mCurrentOperation's notifyPreparing signal.
+ * \a currentStep indicates the current length of progress bar.
+ */
+void FmOperationService::on_operation_notifyProgress( int currentStep )
{
mOperationResultProcesser->onNotifyProgress(
mCurrentOperation, currentStep );
emit notifyProgress( mCurrentOperation, currentStep );
}
-void FmOperationService::on_operationThread_notifyFinish()
+
+/*
+ * Responds to mCurrentOperation's notifyFinish signal, indicate the
+ * progress is over.
+ */
+void FmOperationService::on_operation_notifyFinish()
{
mOperationResultProcesser->onNotifyFinish( mCurrentOperation );
emit notifyFinish( mCurrentOperation );
resetOperation();
}
-void FmOperationService::on_operationThread_notifyError(int error, QString errString )
+
+/*
+ * Responds to mCurrentOperation's notifyError signal.
+ * \a error error id.
+ * \a errString the error string.
+ */
+void FmOperationService::on_operation_notifyError(int error, QString errString )
{
mOperationResultProcesser->onNotifyError(
mCurrentOperation, error, errString );
emit notifyError( mCurrentOperation, error, errString );
resetOperation();
}
-void FmOperationService::on_operationThread_notifyCanceled()
+
+/*
+ * Responds to mCurrentOperation's driveSpaceChanged
+ */
+void FmOperationService::on_operation_driveSpaceChanged()
{
- mOperationResultProcesser->onNotifyCanceled(
- mCurrentOperation );
- emit notifyCanceled( mCurrentOperation );
- resetOperation();
+ emit driveSpaceChanged( mCurrentOperation );
}
-///
-/////////////////////////////////////////////////////
-/////////////////////////////////////////////////////
-///BackupRestore
+/*
+ * Responds to mBackupRestoreHandler's notifyPreparing
+ * \a cancelable indicates whether it could be cancelled.
+ */
void FmOperationService::on_backupRestore_notifyPreparing( bool cancelable )
{
mOperationResultProcesser->onNotifyPreparing(
mCurrentOperation, cancelable );
emit notifyPreparing( mCurrentOperation, cancelable );
}
+
+/*
+ * Responds to mBackupRestoreHandler's notifyStart
+ * \a cancelable indicates whether it could be cancelled.
+ * \a maxSteps the lenth of progress bar.
+ */
void FmOperationService::on_backupRestore_notifyStart( bool cancelable, int maxSteps )
{
mOperationResultProcesser->onNotifyStart(
mCurrentOperation, cancelable, maxSteps );
emit notifyStart( mCurrentOperation, cancelable, maxSteps );
}
+
+/*
+ * Responds to mBackupRestoreHandler's notifyProgress
+ * \a currentStep the current progress bar's step.
+ */
void FmOperationService::on_backupRestore_notifyProgress( int currentStep )
{
mOperationResultProcesser->onNotifyProgress(
mCurrentOperation, currentStep );
emit notifyProgress( mCurrentOperation, currentStep );
}
+
+/*
+ * Responds to mBackupRestoreHandler's notifyFinish
+ */
void FmOperationService::on_backupRestore_notifyFinish()
{
mOperationResultProcesser->onNotifyFinish( mCurrentOperation );
emit notifyFinish( mCurrentOperation );
resetOperation();
}
-void FmOperationService::on_backupRestore_notifyError(int error, QString errString )
+
+/*
+ * Responds to mBackupRestoreHandler's notifyError
+ * \a error the error id.
+ * \a errString the error string.
+ */
+void FmOperationService::on_backupRestore_notifyError(int error, const QString &errString )
{
mOperationResultProcesser->onNotifyError(
mCurrentOperation, error, errString );
emit notifyError( mCurrentOperation, error, errString );
resetOperation();
}
+
+/*
+ * Responds to mBackupRestoreHandler's notifyCanceled
+ */
void FmOperationService::on_backupRestore_notifyCanceled()
{
- mOperationResultProcesser->onNotifyCanceled(
- mCurrentOperation );
- emit notifyCanceled( mCurrentOperation );
+ mOperationResultProcesser->onNotifyError(
+ mCurrentOperation, FmErrCancel, QString() );
+ emit notifyError( mCurrentOperation, FmErrCancel, QString() );
resetOperation();
}
--- a/filemanager/src/filemanager/src/operationservice/fmoperationservice.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationservice.h Wed Aug 18 09:39:39 2010 +0300
@@ -57,17 +57,17 @@
//return error if any path exist.
//renturn error if list count is not as the same the other.
- int asyncCopy( QStringList sourceList, QString targetPath );
+ int asyncCopy( const QStringList &sourceList, const QString &targetPath );
- int asyncMove( QStringList sourceList, QString targetPath );
+ int asyncMove( const QStringList &sourceList, const QString &targetPath );
- int asyncRemove( QStringList pathList );
+ int asyncRemove( const QStringList &pathList );
//return error if can not be format.
//notify error while format error.
- int asyncFormat( QString driverName );
- int asyncViewDriveDetails( const QString driverName );
- int asyncViewFolderDetails( const QString folderPath );
+ int asyncFormat( const QString &driverName );
+ int asyncViewDriveDetails( const QString &driverName );
+ int asyncViewFolderDetails( const QString &folderPath );
int asyncBackup();
int asyncRestore( quint64 selection );
@@ -89,24 +89,22 @@
void on_backupRestore_notifyStart( bool cancelable, int maxSteps );
void on_backupRestore_notifyProgress( int currentStep );
void on_backupRestore_notifyFinish();
- void on_backupRestore_notifyError(int error, QString errString );
+ void on_backupRestore_notifyError(int error, const QString &errString );
void on_backupRestore_notifyCanceled();
-
- 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_showNote( const char *noteString );
- void on_operationThread_notifyWaiting( bool cancelable );
- void on_operationThread_notifyPreparing( bool cancelable );
- void on_operationThread_notifyStart( bool cancelable, int maxSteps );
- void on_operationThread_notifyProgress( int currentStep );
- void on_operationThread_notifyFinish();
- void on_operationThread_notifyError(int error, QString errString );
- void on_operationThread_notifyCanceled();
+ void on_operation_askForRename( const QString &srcFile, QString *destFile );
+ void on_operation_askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
+ void on_operation_showNote( const char *noteString );
+ void on_operation_notifyWaiting( bool cancelable );
+ void on_operation_notifyPreparing( bool cancelable );
+ void on_operation_notifyStart( bool cancelable, int maxSteps );
+ void on_operation_notifyProgress( int currentStep );
+ void on_operation_notifyFinish();
+ void on_operation_notifyError(int error, QString errString );
+ void on_operation_driveSpaceChanged();
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.
@@ -119,6 +117,7 @@
private:
void resetOperation();
+ void connectSignalsAndSlots( FmOperationBase *operation );
private:
FmOperationThread *mThread;
--- a/filemanager/src/filemanager/src/operationservice/fmoperationthread.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationthread.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -17,288 +17,59 @@
*/
#include "fmoperationthread.h"
-#include "fmoperationbase.h"
-#include "fmdrivedetailstype.h"
-#include "fmcommon.h"
-#include "fmoperationcopy.h"
-#include "fmoperationmove.h"
-#include "fmoperationremove.h"
-#include "fmoperationformat.h"
+#include "fmbackuprestorehandler.h"
#include <QDir>
#include <QStack>
-FmOperationThread::FmOperationThread( QObject *parent ) : QThread( parent ), mOperationBase( 0 )
+/*
+ * Constructs the operation thread with \a parent.
+ */
+FmOperationThread::FmOperationThread( QObject *parent ) : QThread( parent ),
+ mStop( false), mOperationBase( 0 )
{
-
-
+ setPriority( LowestPriority );
}
+/*
+ * Destructs the operation thread.
+ */
FmOperationThread::~FmOperationThread()
{
}
-int FmOperationThread::asyncCopy( FmOperationBase* operationBase )
-{
- if( isRunning() ){
- return FmErrAlreadyStarted;
+/*
+ * Prepare some conditions before starts the operation.
+ * Returns the error id.
+ * \a operationBase the operation to be prepared.
+ */
+int FmOperationThread::prepareOperationAndStart( FmOperationBase* operationBase )
+{
+ if ( isRunning() ) {
+ return FmErrAlreadyStarted;
}
-
mOperationBase = operationBase;
- mOperationBase->setObjectName( "operationElement" );
- QMetaObject::connectSlotsByName( this );
- connect( mOperationBase, SIGNAL( askForRename( QString, QString* ) ),
- this, SLOT( onAskForRename( QString, QString* )), Qt::BlockingQueuedConnection );
- connect( mOperationBase, SIGNAL( askForReplace( QString, QString, bool* ) ),
- this, SLOT( onAskForReplace( QString, QString, bool* )), Qt::BlockingQueuedConnection );
- connect( mOperationBase, SIGNAL( showNote( QString ) ),
- this, SLOT( onShowNote( QString )), Qt::BlockingQueuedConnection );
-
- start();
- return FmErrNone;
-}
-
-int FmOperationThread::asyncMove( FmOperationBase* operationBase )
-{
- if( isRunning() ){
- return FmErrAlreadyStarted;
- }
-
- mOperationBase = operationBase;
- mOperationBase->setObjectName( "operationElement" );
- QMetaObject::connectSlotsByName( this );
- connect( mOperationBase, SIGNAL( askForRename( QString, QString* ) ),
- this, SLOT( onAskForRename( QString, QString* )), Qt::BlockingQueuedConnection );
- connect( mOperationBase, SIGNAL( askForReplace( QString, QString, bool* ) ),
- this, SLOT( onAskForReplace( QString, QString, bool* )), Qt::BlockingQueuedConnection );
- connect( mOperationBase, SIGNAL( showNote( QString ) ),
- this, SLOT( onShowNote( QString )), Qt::BlockingQueuedConnection );
-
-
- start();
- return FmErrNone;
+ int ret = mOperationBase->prepare();
+ if ( ret == FmErrNone ) {
+ mStop = false;
+ start();
+ }
+ return ret;
}
-int FmOperationThread::asyncRemove( FmOperationBase* operationBase )
-{
- if( isRunning() ){
- return FmErrAlreadyStarted;
- }
-
- mOperationBase = operationBase;
- mOperationBase->setObjectName( "operationElement" );
- QMetaObject::connectSlotsByName( this );
-
- start();
- return FmErrNone;
-}
-
-int FmOperationThread::asyncFormat( FmOperationBase* operationBase )
-{
- if( isRunning() ){
- return FmErrAlreadyStarted;
- }
-
- mOperationBase = operationBase;
- mOperationBase->setObjectName( "operationElement" );
- QMetaObject::connectSlotsByName( this );
-
- start();
- return FmErrNone;
-}
-int FmOperationThread::asyncViewDriveDetails( FmOperationBase* operationBase )
-{
- if( isRunning() ){
- return FmErrAlreadyStarted;
- }
-
- mOperationBase = operationBase;
- mOperationBase->setObjectName( "operationElement" );
- QMetaObject::connectSlotsByName( this );
-
- start();
- return FmErrNone;
-}
-
-int FmOperationThread::asyncViewFolderDetails( FmOperationBase* operationBase )
-{
- if( isRunning() ){
- return FmErrAlreadyStarted;
- }
-
- mOperationBase = operationBase;
- mOperationBase->setObjectName( "operationElement" );
- QMetaObject::connectSlotsByName( this );
-
- start();
- return FmErrNone;
-}
-
-
+/* Stops the current thread.
+ * Caused by user interaction.
+ */
void FmOperationThread::stop()
{
mStop = true;
}
-void FmOperationThread::onAskForRename( const QString &srcFile, QString *destFile )
-{
- emit askForRename( srcFile, destFile );
-}
-void FmOperationThread::onAskForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted )
-{
- emit askForReplace( srcFile, destFile, isAccepted );
-}
-
-void FmOperationThread::onShowNote( const char *noteString )
-{
- emit showNote( noteString );
-}
-
-void FmOperationThread::on_operationElement_notifyPreparing( bool cancelable )
-{
- emit notifyPreparing( cancelable );
-}
-void FmOperationThread::on_operationElement_notifyStart( bool cancelable, int maxSteps )
-{
- emit notifyStart( cancelable, maxSteps );
-}
-void FmOperationThread::on_operationElement_notifyProgress( int currentStep )
-{
- emit notifyProgress( currentStep );
+/*
+ * reimp
+ */
+void FmOperationThread::run()
+{
+ mOperationBase->start( &mStop );
}
-void FmOperationThread::run()
-{
- mStop = false;
- this->setPriority( LowestPriority );
- switch( mOperationBase->operationType() )
- {
- case FmOperationService::EOperationTypeCopy:
- {
- mErrString.clear();
- FmOperationCopy *operationCopy = static_cast<FmOperationCopy*>(mOperationBase);
- QString refreshDestPath = QFileInfo( operationCopy->targetPath() ).dir().absolutePath();
-
- int ret = operationCopy->start( &mStop, &mErrString );
- switch( ret )
- {
- case FmErrCancel:
- emit notifyCanceled();
- 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("") );
- break;
- }
- case FmOperationService::EOperationTypeMove:
- {
- mErrString.clear();
- FmOperationMove *operationMove = static_cast<FmOperationMove*>(mOperationBase);
-
- QString refreshSrcPath = QFileInfo( operationMove->sourceList().front() ).dir().absolutePath();
-
- int ret = operationMove->start( &mStop, &mErrString );
- switch( ret )
- {
- case FmErrCancel:
- emit notifyCanceled();
- 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("") );
- break;
- }
- case FmOperationService::EOperationTypeRemove:
- {
- mErrString.clear();
- FmOperationRemove *operationRemove = static_cast<FmOperationRemove*>(mOperationBase);
-
- QString refreshSrcPath = QFileInfo( operationRemove->pathList().front() ).dir().absolutePath();
-
- int ret = operationRemove->start( &mStop, &mErrString );
- switch( ret )
- {
- case FmErrCancel:
- emit notifyCanceled();
- break;
- case FmErrNone:
- emit notifyFinish();
- break;
- default:
- emit notifyError( ret, mErrString );
- }
- // refresh driveview no care if cancel, error or finished.
- emit refreshModel( QString("") );
- break;
- }
- case FmOperationService::EOperationTypeFormat:
- {
-// emit notifyWaiting( false );
- FmLogger::log(QString("start format"));
- FmOperationFormat *operationFormat = static_cast<FmOperationFormat*>( mOperationBase );
- FmLogger::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"));
- emit notifyFinish();
- emit refreshModel( refreshSrcPath );
- FmLogger::log(QString("format done and emit finish"));
- break;
- }
- case FmOperationService::EOperationTypeDriveDetails:
- {
- emit notifyWaiting( true );
-
- FmOperationDriveDetails *operationDriverDetails = static_cast<FmOperationDriveDetails*>( mOperationBase );
- int ret = FmDriveDetailsContent::querySizeofContent(
- operationDriverDetails->driverName(), operationDriverDetails->detailsSizeList(), &mStop );
- if( ret == FmErrNone ) {
- emit notifyFinish();
- } else if( ret == FmErrCancel ) {
- emit notifyCanceled();
- }
-
- break;
- }
- case FmOperationService::EOperationTypeFolderDetails:
- {
- emit notifyWaiting( true );
-
- FmOperationFolderDetails *operationFolderDetails = static_cast<FmOperationFolderDetails*>( mOperationBase );
- int ret = FmFolderDetails::getNumofSubfolders( operationFolderDetails->folderPath(), operationFolderDetails->numofSubFolders(),
- operationFolderDetails->numofFiles(), operationFolderDetails->sizeofFolder(),
- &mStop );
- if( ret == FmErrNone ) {
- emit notifyFinish();
- } else if( ret == FmErrCancel ) {
- emit notifyCanceled();
- }
-
- break;
-
- }
- default:
- Q_ASSERT( false );
-
- }
-}
-
--- a/filemanager/src/filemanager/src/operationservice/fmoperationthread.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationthread.h Wed Aug 18 09:39:39 2010 +0300
@@ -19,7 +19,7 @@
#ifndef FMOPERATIONTHREAD_H
#define FMOPERATIONTHREAD_H
-#include "fmoperationservice.h"
+#include "fmoperationbase.h"
#include "fmcommon.h"
#include <QString>
@@ -27,51 +27,14 @@
#include <QThread>
-class FmDriveDetailsSize;
-class FmOperationBase;
-
-class FmOperationCopy;
-class FmOperationMove;
-class FmOperationRemove;
-
class FmOperationThread : public QThread
{
Q_OBJECT
public:
FmOperationThread( QObject *parent );
~FmOperationThread();
-
- int asyncCopy( FmOperationBase* operationBase );
- int asyncMove( FmOperationBase *operationBase );
- int asyncRemove( FmOperationBase *operationBase );
-
- int asyncFormat( FmOperationBase *operationBase );
- int asyncViewDriveDetails( FmOperationBase *operationBase );
- int asyncViewFolderDetails( FmOperationBase *operationBase );
- void stop();
-
-signals:
- void askForRename( const QString &srcFile, QString *destFile );
- void askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
- void refreshModel( const QString &path );
-
- void showNote(const char*);
- void notifyWaiting( bool cancelable );
- void notifyPreparing( bool cancelable ); // this step could not be used if not needed.
- void notifyStart( bool cancelable, int maxSteps );
- void notifyProgress( int currentStep );
-
- void notifyFinish();
- void notifyError(int error, QString errString );
- void notifyCanceled();
-
-private slots:
- void onAskForRename( const QString &srcFile, QString *destFile );
- void onAskForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted );
- void onShowNote( const char *noteString );
- void on_operationElement_notifyPreparing( bool cancelable );
- void on_operationElement_notifyStart( bool cancelable, int maxSteps );
- void on_operationElement_notifyProgress( int currentStep );
+ int prepareOperationAndStart( FmOperationBase* operationBase );
+ void stop();
protected:
void run();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationviewdetails.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* The source file of the operation param of file manager
+*
+*/
+
+#include "fmoperationviewdetails.h"
+#include "fmdrivedetailstype.h"
+#include <QtAlgorithms>
+
+/*
+ * Constructs one view drive details operation with
+ * \a parent parent.
+ * \a driverName the drive name.
+ */
+FmOperationDriveDetails::FmOperationDriveDetails( QObject *parent, const QString &driverName ) :
+ FmOperationBase( parent, FmOperationService::EOperationTypeDriveDetails ),
+ mDriverName( driverName ), mStop( 0 )
+{
+}
+
+/*
+ * Destructs the operation.
+ */
+FmOperationDriveDetails::~FmOperationDriveDetails()
+{
+ qDeleteAll(mDetailsSizeList);
+}
+
+/*
+ * Returns the drive name.
+ */
+QString FmOperationDriveDetails::driverName()
+{
+ return mDriverName;
+}
+
+/*
+ * reimp.
+ */
+void FmOperationDriveDetails::start( volatile bool *isStopped )
+{
+ mStop = isStopped;
+ emit notifyWaiting( true );
+ //FmOperationDriveDetails *operationDriverDetails = static_cast<FmOperationDriveDetails*>( mOperationBase );
+ int ret = FmDriveDetailsContent::querySizeofContent( driverName(), detailsSizeList(), mStop );
+ if( ret == FmErrNone ) {
+ emit notifyFinish();
+ } else {
+ emit notifyError( ret, QString() );
+ }
+}
+
+/*
+ * Returns detail items size list.
+ */
+QList<FmDriveDetailsSize*> &FmOperationDriveDetails::detailsSizeList()
+{
+ return mDetailsSizeList;
+}
+
+/*
+ * Constructs one view folder details operation with
+ * \a parent parent.
+ * \a driverName the drive name.
+ */
+FmOperationFolderDetails::FmOperationFolderDetails( QObject *parent, const QString &folderPath ) :
+ FmOperationBase( parent, FmOperationService::EOperationTypeFolderDetails ),
+ mFolderPath( folderPath ),
+ mNumofSubFolders( 0 ),
+ mNumofFiles( 0 ),
+ mSizeofFolder( 0 )
+
+{
+}
+
+/*
+ * Destructs the operation.
+ */
+FmOperationFolderDetails::~FmOperationFolderDetails()
+{
+
+}
+
+/*
+ * Returns the folder path.
+ */
+QString FmOperationFolderDetails::folderPath()
+{
+ return mFolderPath;
+}
+
+/*
+ * Returns the number of sub folders.
+ */
+int &FmOperationFolderDetails::numofSubFolders()
+{
+ return mNumofSubFolders;
+}
+
+/*
+ * Returns the number of files
+ */
+int &FmOperationFolderDetails::numofFiles()
+{
+ return mNumofFiles;
+}
+
+/*
+ * Returns the size of folder.
+ */
+quint64 &FmOperationFolderDetails::sizeofFolder()
+{
+ return mSizeofFolder;
+}
+
+/*
+ * Reimp.
+ */
+void FmOperationFolderDetails::start( volatile bool *isStopped )
+{
+ mStop = isStopped;
+ emit notifyWaiting( true );
+ int ret = FmFolderDetails::getNumofSubfolders( folderPath(), numofSubFolders(),
+ numofFiles(), sizeofFolder(), mStop );
+ if( ret == FmErrNone ) {
+ emit notifyFinish();
+ } else {
+ emit notifyError( ret, QString() );
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/filemanager/src/filemanager/src/operationservice/fmoperationviewdetails.h Wed Aug 18 09:39:39 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* The header file of the operation param of file manager
+*
+*/
+
+#ifndef FMOPERATIONVIEWDETAILS_H
+#define FMOPERATIONVIEWDETAILS_H
+
+#include "fmoperationservice.h"
+#include "fmoperationbase.h"
+
+#include <QObject>
+#include <QString>
+
+class FmOperationDriveDetails : public FmOperationBase
+{
+public:
+ explicit FmOperationDriveDetails( QObject *parent, const QString &driverName );
+
+ virtual ~FmOperationDriveDetails();
+ QString driverName();
+ virtual void start( volatile bool *isStopped );
+ QList<FmDriveDetailsSize*> &detailsSizeList();
+
+private:
+ QString mDriverName;
+ QList<FmDriveDetailsSize*> mDetailsSizeList;
+ volatile bool *mStop;
+};
+
+class FmOperationFolderDetails : public FmOperationBase
+{
+public:
+ explicit FmOperationFolderDetails( QObject *parent, const QString &folderPath );
+
+ virtual ~FmOperationFolderDetails();
+ virtual void start( volatile bool *isStopped );
+
+ QString folderPath();
+ int &numofSubFolders();
+ int &numofFiles();
+ quint64 &sizeofFolder();
+
+private:
+ QString mFolderPath;
+ int mNumofSubFolders;
+ int mNumofFiles;
+ quint64 mSizeofFolder;
+ volatile bool *mStop;
+};
+#endif
--- a/filemanager/src/fmbkupengine/inc/CMMCScBkupOperationParameters.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/fmbkupengine/inc/CMMCScBkupOperationParameters.h Wed Aug 18 09:39:39 2010 +0300
@@ -39,7 +39,7 @@
_LIT( KBackUpFolder, "\\Backup\\" );
_LIT( KBackUpFiles, "*.arc" );
-
+const TInt KCArrayGranularity = 10;
class TBkupDrivesAndOperation
{
@@ -86,9 +86,9 @@
}
void ConstructL()
{
- mUids = new ( ELeave ) CArrayFixFlat<unsigned int>( 10 );
- mExclude_uids = new ( ELeave ) CArrayFixFlat<unsigned int>( 10 );
- mArchive_name = HBufC::NewL(1);
+ mUids = new ( ELeave ) CArrayFixFlat<unsigned int>( KCArrayGranularity );
+ mExclude_uids = new ( ELeave ) CArrayFixFlat<unsigned int>( KCArrayGranularity );
+ mArchive_name = 0;
}
~CBkupCategory()
@@ -105,8 +105,11 @@
void setArchive_name( TDesC16& archive_name )
{
- delete mArchive_name;
- mArchive_name = HBufC::NewL( archive_name.Length() );
+ if ( mArchive_name != 0 )
+ {
+ delete mArchive_name;
+ }
+ TRAP_IGNORE( mArchive_name = HBufC::NewL( archive_name.Length() ) );
*mArchive_name = archive_name;
}
@@ -122,12 +125,12 @@
void addUids( unsigned int uid )
{
- mUids->AppendL( uid, sizeof(unsigned int));
+ TRAP_IGNORE( mUids->AppendL( uid, sizeof(unsigned int) ) );
}
void addExclude_uids( unsigned int exclude_uid )
{
- mExclude_uids->AppendL( exclude_uid, sizeof(unsigned int) );
+ TRAP_IGNORE( mExclude_uids->AppendL( exclude_uid, sizeof(unsigned int) ) );
}
unsigned int category() { return mCategory; }
--- a/filemanager/src/fmbkupengine/src/CMMCScBkupStateArchiveOpPublicDataFiles.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/fmbkupengine/src/CMMCScBkupStateArchiveOpPublicDataFiles.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -373,8 +373,7 @@
// progress info. See CMMCScBkupStateRequestListOfPublicFiles::PerformLastRightsL()
// for the point when the public data size is zeroed.
- // First, find the associated data owner.
- CMMCScBkupDataOwnerInfo& owner = dataOwners.OwnerL( fileInfo.SecureId() );
+
__LOG3("CMMCScBkupStateArchiveOpPublicDataFiles::AddIndexRecordL() - offset: %6d, length: %6d, file: %S", info.Offset(), info.Length(), &fileInfo.FileName());
--- a/filemanager/src/fmbkupengine/src/CMMCScBkupStateValidateDiskSpace.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/fmbkupengine/src/CMMCScBkupStateValidateDiskSpace.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -188,18 +188,18 @@
// Calculate the total progress required for the entire backup operation
uncompressedSize = dataOwners.TotalOperationalSizeL();
__LOG1("CMMCScBkupStateValidateDiskSpace::ValidateFreeSpaceBeforeBackupL() - Total estimated uncompressed size for archive %Ld", uncompressedSize);
- const TInt ownerCount = dataOwners.Count();
+ //const TInt ownerCount = dataOwners.Count();
- for( TInt i=0; i<ownerCount; i++ )
- {
- CMMCScBkupDataOwnerInfo& owner = dataOwners.Owner( i );
+ //for( TInt i=0; i<ownerCount; i++ )
+ // {
+ // CMMCScBkupDataOwnerInfo& owner = dataOwners.Owner( i );
// Reset the size of public data to 0. We update this value
// with the compressed size during the compression stage. This
// is needed in order to create accurate restore information (since
// all of the data owner sizing info is written to disk).
// owner.ResetOperationalSize( EMMCScBkupOwnerDataTypePublicData );
- }
-
+ // }
+
// Let's check do public files fit in target drive
TInt driveNumber;
TDriveInfo driveInfo;
--- a/filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/fmbkupenginewrapper/fmbkupenginewrapper.pro Wed Aug 18 09:39:39 2010 +0300
@@ -28,7 +28,7 @@
TARGET.UID3 = 0x2002BCC1
TARGET.EPOCALLOWDLLDATA = 1
TARGET.CAPABILITY = CAP_GENERAL_DLL DiskAdmin AllFiles PowerMgmt
- TARGET.VENDORID = VID_DEFAULT
+ TARGET.VID = VID_DEFAULT
LIBS += -lfmbkupengine
LIBS += -lefsrv
LIBS += -lavkon
--- a/filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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:
@@ -554,8 +554,6 @@
iDrvAndOpList->AppendL( drvAndOp );
}
////////
-
- FmBackupSettings& bkupSettings( *( q->BackupSettingsL() ) );
// Create restore params - ownership is transferred to
// secure backup engine
@@ -634,6 +632,7 @@
CMMCScBkupOpParamsRestoreFull::NewL( driveReader, EBUCatAllInOne );
CleanupStack::PopAndDestroy(); // driveReader
+ FmBackupSettings& bkupSettings( *( q->BackupSettingsL() ) );
// Get list of all archives
RPointerArray< CMMCScBkupArchiveInfo > archives;
TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
@@ -670,8 +669,7 @@
QList< FmRestoreInfo > &restoreInfoList,
const QString& aDrive )
{
- int targetDrive = DriverNameToNumber( aDrive );
- FmBackupSettings& settings( *( q->BackupSettingsL() ) );
+ int targetDrive = DriverNameToNumber( aDrive );
restoreInfoList.clear();
--- a/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/fmfiledialog/src/fmfilewidget.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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/commoninc.pri Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/commoninc.pri Wed Aug 18 09:39:39 2010 +0300
@@ -16,6 +16,7 @@
INTERNAL_HEADERS += $$PWD/fmcommon.h \
$$PWD/fmlogger.h \
- $$PWD/fmdefine.h \
+ $$PWD/fmdefine.h
-HEADERS += $$INTERNAL_HEADERS
\ No newline at end of file
+HEADERS += $$INTERNAL_HEADERS
+
--- a/filemanager/src/inc/fmdefine.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmdefine.h Wed Aug 18 09:39:39 2010 +0300
@@ -71,4 +71,22 @@
#define FmMaxLengthofDriveName 11
#define FmMaxLengthofDrivePassword 8
+// used to match un-zeroLength string, empty character such as space is acceptable
+#define Regex_ValidUnZeroLength QString( "^.+$" )
+
+// used to match un-empty string, and is not totally empty characters.
+#define Regex_ValidUnEmpty QString( "^.*[^\\s].*$" )
+
+// this is regexp for vaild file/folder name: no \/:*?"<>| and is not totally empty characters.
+// file name can not end with "." , but it is not include in this RegExp. It should be checked in Regex_ValidNotEndWithDot
+// this expression is composed by two expressions:
+// ^.*[^\\s].*$ used to match un-empty string and is not totally empty characters.
+// [^\\\\/:*?\"<>|] used to math valid file/folder name
+// merge the two regex together:
+// vaild file/folder name and is not totally empty.
+#define Regex_ValidFileFolderName QString( "^[^\\\\/:*?\"<>|]*[^\\\\/:*?\"<>|\\s][^\\\\/:*?\"<>|]*$" )
+
+// is not end with dot( trim blank characters in the end first )
+#define Regex_ValidNotEndWithDot QString( "^.*[^\\.\\s][\\s]*$" )
+
#endif
--- a/filemanager/src/inc/fmdrivemodel.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmdrivemodel.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmdrivewatcher/private/symbian/fmdriveevent.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmdrivewatcher/private/symbian/fmdrivewatcherprivate.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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/fmfileiconprovider.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmfileiconprovider.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -76,40 +76,30 @@
{
case FmFileTypeRecognizer::FileTypeDrive:
{
- FmDriverInfo::DriveState driveState = FmUtils::queryDriverInfo( filePath ).driveState();
- if( driveState & FmDriverInfo::EDriveAvailable ){
- if( driveState & FmDriverInfo::EDriveRemovable ) {
- if( driveState & FmDriverInfo::EDriveMassStorage ) {
- // Mass Storage
- retIcon = HbIcon( massMemoryIcon ).qicon();
- break;
- } else if( driveState & FmDriverInfo::EDriveUsbMemory ) {
- // Usb Memory
- retIcon = HbIcon( usbMemoryIcon ).qicon();
- break;
- } else{
- //Memory Card
+ FmDriverInfo driveInfo = FmUtils::queryDriverInfo( filePath );
+ switch ( driveInfo.driveType() )
+ {
+ case FmDriverInfo::EDriveTypeMassStorage:
+ retIcon = HbIcon( massMemoryIcon ).qicon();
+ break;
+ case FmDriverInfo::EDriveTypeUsbMemory:
+ retIcon = HbIcon( usbMemoryIcon ).qicon();
+ break;
+ case FmDriverInfo::EDriveTypeMemoryCard:
+ if( !( driveInfo.driveState() & FmDriverInfo::EDriveNotPresent ) ) {
retIcon = HbIcon( mmcIcon ).qicon();
- break;
+ } else {
+ retIcon = HbIcon( mmcNoneIcon ).qicon();
}
- } else{
- //Phone Memory
+ break;
+ case FmDriverInfo::EDriveTypePhoneMemory:
retIcon = HbIcon( phoneMemoryIcon ).qicon();
break;
+ default:
+ Q_ASSERT_X( false, "FmFileIconProvider::icon", "please handle drive type");
+ break;
}
- } else if( driveState & FmDriverInfo::EDriveLocked ) {
- retIcon = HbIcon( mmcLockedIcon ).qicon();
- break;
- } else if( driveState & FmDriverInfo::EDriveCorrupted ) {
- retIcon = HbIcon( mmcNoneIcon ).qicon();
- break;
- } else if( driveState & FmDriverInfo::EDriveNotPresent ){
- retIcon = HbIcon( mmcNoneIcon ).qicon();
- break;
- } else {
- retIcon = HbIcon( mmcNoneIcon ).qicon();
- break;
- }
+ break;
}
case FmFileTypeRecognizer::FileTypeFolder:
{
--- a/filemanager/src/inc/fmfiletyperecognizer.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmfiletyperecognizer.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmfiletyperecognizer.h Wed Aug 18 09:39:39 2010 +0300
@@ -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 Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmlogger.h Wed Aug 18 09:39:39 2010 +0300
@@ -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.h Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmutils.h Wed Aug 18 09:39:39 2010 +0300
@@ -26,6 +26,10 @@
class FmDriverInfo
{
public:
+ /*!
+ Used to get drive status for convenience.
+ /sa DriveType is used to get drive type.
+ */
enum driveState
{
EDriveNotPresent = 0x1, // true when Drive have not inserted, for example, MMC Card
@@ -46,7 +50,23 @@
EDriveMassStorage = 0x8000,
EDriveRam = 0x10000,
EDriveUsbMemory = 0x20000,
+ EDriveRemote = 0x40000,
};
+
+ /*!
+ Used to get drive type for convenience.
+ */
+ enum DriveType
+ {
+ EDriveTypeRom,
+ EDriveTypeRam,
+ EDriveTypePhoneMemory,
+ EDriveTypeMassStorage,
+ EDriveTypeMemoryCard,
+ EDriveTypeUsbMemory,
+ EDriveTypeRemote,
+ };
+
Q_DECLARE_FLAGS( DriveState, driveState )
FmDriverInfo( quint64 s, quint64 f, const QString &n, const QString &vN, const quint32 driveState ) :
@@ -71,6 +91,7 @@
QString name() const { return mName; }
QString volumeName() const { return mVolumeName; }
DriveState driveState() const { return mDriveState; }
+ FmDriverInfo::DriveType driveType();
private:
quint64 mSize;
@@ -78,6 +99,7 @@
QString mName;
QString mVolumeName;
DriveState mDriveState;
+ DriveType mDriveType;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( FmDriverInfo::DriveState )
@@ -127,12 +149,24 @@
/**
* check file or folder path is illegal or not.
*
- * @param path file/folder path.
+ * @param fileName file/folder name, used to check illegal characters
+ * @param path file/folder path, used to check if path is available to use.
* @param errString if return false, errString will be set for error note.
* @return true for not illegal and false for illegal path.
*/
- static bool checkNewFolderOrFile( const QString &path, QString &errString );
+ static bool checkNewFolderOrFile( const QString& fileName, const QString &path, QString &errString );
+
+ /*
+ * get the volume name of the disk, if it is null, then return the default name.
+ * @param diskName the driver letter.
+ * @param defaultName whether it is the default name.
+ * @return the volume name.
+ */
+ static QString getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName );
+ static bool isSubLevelPath( const QString &src, const QString &dest );
+
+ static int setFileAttributes( const QString &srcFile, const QString &desFile );
};
#endif
--- a/filemanager/src/inc/fmutils_s60.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmutils_s60.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -36,7 +36,8 @@
#include <QFileInfoList>
#include <QDir>
#include <QFile>
-
+#include <QIODevice>
+#include <XQConversions>
#include <hbglobal.h>
#include <xqaiwrequest.h>
@@ -46,6 +47,34 @@
#define BURCONFIGFILE "z:/private/2002BCC0/burconfig.xml"
+
+/*!
+ Used to get drive type for convenience.
+*/
+FmDriverInfo::DriveType FmDriverInfo::driveType()
+{
+ FmDriverInfo::DriveType driveType;
+ if( mDriveState & FmDriverInfo::EDriveRemovable ) {
+ if( mDriveState & FmDriverInfo::EDriveMassStorage ) {
+ driveType = FmDriverInfo::EDriveTypeMassStorage;
+ } else if( mDriveState & FmDriverInfo::EDriveUsbMemory ) {
+ driveType = FmDriverInfo::EDriveTypeUsbMemory;
+ } else if( mDriveState & FmDriverInfo::EDriveRemote ){
+ driveType = FmDriverInfo::EDriveTypeRemote;
+ } else {
+ driveType = FmDriverInfo::EDriveTypeMemoryCard;
+ }
+ } else if( mDriveState & FmDriverInfo::EDriveRom ) {
+ driveType = FmDriverInfo::EDriveTypeRom;
+ } else if( mDriveState & FmDriverInfo::EDriveRam ) {
+ driveType = FmDriverInfo::EDriveTypeRam;
+ } else {
+ driveType = FmDriverInfo::EDriveTypePhoneMemory;
+ }
+
+ return driveType;
+}
+
QString FmUtils::getDriveNameFromPath( const QString &path )
{
// fillPathWithSplash make sure path length will be at least 3 if it is not empty.
@@ -94,7 +123,7 @@
}
}
- if( volumeName == KErrNone || driveInfoErr == KErrNone ) {
+ if( volumeInfoErr == KErrNone || driveInfoErr == KErrNone ) {
//TDriveInfo driveInfo = volumeInfo.iDrive;
quint32 drvStatus( 0 );
@@ -112,7 +141,12 @@
{
state |= FmDriverInfo::EDriveUsbMemory;
}
-
+
+ if ( drvStatus & DriveInfo::EDriveRemote )
+ {
+ state |= FmDriverInfo::EDriveRemote;
+ }
+
if ( drvStatus & DriveInfo::EDriveRom ){
state |= FmDriverInfo::EDriveRom;
}
@@ -195,7 +229,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 );
}
@@ -214,20 +248,20 @@
int FmUtils::removeDrivePwd( const QString &driverName, const QString &Pwd )
{
- if( driverName.isEmpty() ) {
+ if( driverName.isEmpty() || Pwd.length() > FmMaxLengthofDrivePassword ) {
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();
TInt drive = 0;
- drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
+ drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
HBufC* password16 = XQConversions::qStringToS60Desc( Pwd );
TMediaPassword password;
@@ -237,10 +271,12 @@
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 );
+
+ delete password16;
if( err == KErrNone ){
return FmErrNone;
@@ -255,13 +291,13 @@
int FmUtils::unlockDrive( const QString &driverName, const QString &Pwd )
{
- if( driverName.isEmpty() ) {
+ if( driverName.isEmpty() || Pwd.length() > FmMaxLengthofDrivePassword ) {
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 +313,11 @@
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 );
+
+ delete password16;
if( err == KErrNone ){
return FmErrNone;
@@ -300,25 +338,26 @@
int FmUtils::checkDrivePwd( const QString &driverName, const QString &pwd )
{
- if( driverName.isEmpty() ) {
+ if( driverName.isEmpty() || pwd.length() > FmMaxLengthofDrivePassword ) {
return FmErrWrongParam;
}
QString logString = "checkDrivePwd Drive name:" + driverName;
logString += " password:" + pwd;
- FmLogger::log( logString );
+ FM_LOG( logString );
return setDrivePwd( driverName, pwd, pwd );
}
int FmUtils::setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd)
{
- if( driverName.isEmpty() ) {
+ if( driverName.isEmpty() ||
+ oldPwd.length() > FmMaxLengthofDrivePassword || newPwd.length() > FmMaxLengthofDrivePassword ) {
return FmErrWrongParam;
}
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,10 +380,12 @@
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 );
+ delete newPassword16;
+ delete oldPassword16;
if( err == KErrNone ){
return FmErrNone;
}
@@ -358,10 +399,10 @@
void FmUtils::emptyPwd( QString &pwd )
{
- TPtr des ( ( XQConversions::qStringToS60Desc( pwd ) )->Des() );
- des.FillZ( des.MaxLength() );
- des.Zero();
- pwd = XQConversions::s60DescToQString( des );
+ TBuf< FmMaxLengthofDrivePassword > nullPwd;
+ nullPwd.FillZ( nullPwd.MaxLength() );
+ nullPwd.Zero();
+ pwd = XQConversions::s60DescToQString( nullPwd );
}
int FmUtils::renameDrive( const QString &driverName, const QString &newVolumeName)
@@ -391,7 +432,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 +451,7 @@
return FmErrWrongParam;
}
QString logString = "FmUtils::ejectDrive start";
- FmLogger::log( logString );
+ FM_LOG( logString );
TInt drive = 0;
drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
@@ -456,7 +497,7 @@
RFs fs;
err = fs.Connect();
- QString string( formatPath( folderPath ) );
+ QString string( fillPathWithSplash( folderPath ) );
TPtrC desFolderPath( XQConversions::qStringToS60Desc( string )->Des() );
TPtrC ptrExtension( XQConversions::qStringToS60Desc( extension )->Des() );
@@ -601,6 +642,11 @@
CleanupStack::PopAndDestroy( array );
}
+/*!
+ fill splash in the end of \a filePath if the path is not a file
+ All "/" and "\" will be changed to QDir::separator
+ \sa formatPath only changed "/" and "\" to QDir::separator
+*/
QString FmUtils::fillPathWithSplash( const QString &filePath )
{
QString newFilePath;
@@ -608,18 +654,11 @@
return newFilePath;
}
- foreach( QChar ch, filePath ) {
- if( ch == QChar('\\') || ch == QChar('/') ) {
- newFilePath.append( QDir::separator() );
- } else {
- newFilePath.append( ch );
- }
- }
+ newFilePath = formatPath( filePath );
if( newFilePath.right( 1 )!= QDir::separator() ){
newFilePath.append( QDir::separator() );
}
-
return newFilePath;
}
@@ -667,14 +706,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;
@@ -684,54 +723,58 @@
int FmUtils::isPathAccessabel( const QString &path )
{
// Used to check if path is accessable, very important feature
- // and will return filemanager error.
- FmLogger::log( QString( "isPathAccessabel:" ) + path );
+ // and will return filemanager error.
+ FM_LOG( QString( "isPathAccessabel:" ) + path );
if( path.isEmpty() ) {
return FmErrPathNotExist;
}
- if( path.length() <= 3 && !isDriveAvailable( path ) ) { //used to filter locked drive
- FmLogger::log( QString( "isPathAccessabel false: path is drive and not available" ) );
+
+ // 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 ) ) {
+ 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();
@@ -749,6 +792,10 @@
return;
}
+/*!
+ fill volume name for \a driveName, with drive letter at the front, for example, C: Phone memory
+ if \a isFillWithDefaultVolume is true, default volume is provided for non-volume drive.
+*/
QString FmUtils::fillDriveVolume( QString driveName, bool isFillWithDefaultVolume )
{
QString ret;
@@ -761,36 +808,73 @@
FmDriverInfo driverInfo = FmUtils::queryDriverInfo( tempDriveName );
QString volumeName = driverInfo.volumeName();
-
+
if( volumeName.isEmpty() && isFillWithDefaultVolume ){
- FmDriverInfo::DriveState driveState = queryDriverInfo( tempDriveName ).driveState();
- if( driveState & FmDriverInfo::EDriveAvailable ){
- if( driveState & FmDriverInfo::EDriveRemovable ) {
- if( driveState & FmDriverInfo::EDriveMassStorage ) {
- // Mass Storage
- ret = hbTrId( "txt_fmgr_dblist_1_mass_storage" ).arg( checkedDriveName );
- } else if( driveState & FmDriverInfo::EDriveUsbMemory ) {
- // USB Memory
- ret = hbTrId( "txt_fmgr_dblist_1_usb_memory" ).arg( checkedDriveName );
- } else{
- // Memory Card
- ret = hbTrId( "txt_fmgr_dblist_1_memory_card" ).arg( checkedDriveName );
- }
- } else{
- // phone memory
+ switch ( driverInfo.driveType() )
+ {
+ case FmDriverInfo::EDriveTypeMassStorage:
+ ret = hbTrId( "txt_fmgr_dblist_1_mass_storage" ).arg( checkedDriveName );
+ break;
+ case FmDriverInfo::EDriveTypeUsbMemory:
+ ret = hbTrId( "txt_fmgr_dblist_1_usb_memory" ).arg( checkedDriveName );
+ break;
+ case FmDriverInfo::EDriveTypeMemoryCard:
+ ret = hbTrId( "txt_fmgr_dblist_1_memory_card" ).arg( checkedDriveName );
+ break;
+ case FmDriverInfo::EDriveTypePhoneMemory:
ret = hbTrId( "txt_fmgr_dblist_1_device_memory" ).arg( checkedDriveName );
- }
- }
+ break;
+ default:
+ Q_ASSERT_X( false, "FmUtils::fillDriveVolume", "please handle drive type");
+ break;
+ }
}
if( ret.isEmpty() ) {
- // set ret as volumeName
+ // ret is not got. fill ret as default method
// txt_fmgr_dblist_1_2 is not correct, can not use.
ret = hbTrId( "%1 %2" ).arg( checkedDriveName ).arg( volumeName );
}
return ret;
}
+
+/*!
+ return volume name for \a driveName. without drive letter at the front.
+ \a defaultName is set true if default volume name is return for volume name
+*/
+QString FmUtils::getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName )
+{
+ FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
+
+ QString volumeName = driverInfo.volumeName();
+ //save the volume status, whether it is default name
+ defaultName = false;
+ //volume name may be null if not set, it will be set at least for one time in the following while cycling.
+ if ( volumeName.isEmpty() ) {
+ defaultName = true;
+ switch ( driverInfo.driveType() )
+ {
+ case FmDriverInfo::EDriveTypeMassStorage:
+ volumeName = hbTrId("Mass storage");
+ break;
+ case FmDriverInfo::EDriveTypeUsbMemory:
+ volumeName = hbTrId("USB memory");
+ break;
+ case FmDriverInfo::EDriveTypeMemoryCard:
+ volumeName = hbTrId("Memory card");
+ break;
+ case FmDriverInfo::EDriveTypePhoneMemory:
+ volumeName = hbTrId("Device memory");
+ break;
+ default:
+ Q_ASSERT_X( false, "FmUtils::getVolumeNameWithDefaultNameIfNull", "please handle drive type" );
+ break;
+ }
+ }
+ return volumeName;
+}
+
int FmUtils::launchFile( const QString &filePath )
{
QFile file( filePath );
@@ -875,7 +959,7 @@
QString FmUtils::Localize( const QString &path )
{
- QString locPath = formatPath( path );
+ QString locPath = fillPathWithSplash( path );
TPtrC desPath( XQConversions::qStringToS60Desc( locPath )->Des() );
CDirectoryLocalizer *localizer = CDirectoryLocalizer::NewL();
@@ -888,9 +972,17 @@
return QString();
}
+/*!
+ All "/" and "\" in \a path will be changed to QDir::separator
+ \sa fillPathWithSplash, fillPathWithSplash will append QDir::separator in the end if path is no a file
+*/
QString FmUtils::formatPath( const QString &path )
{
QString formatPath;
+ if( path.isEmpty() ) {
+ return formatPath;
+ }
+
foreach( QChar ch, path ) {
if( ch == QChar('\\') || ch == QChar('/') ) {
formatPath.append( QDir::separator() );
@@ -899,9 +991,6 @@
}
}
- if( formatPath.right( 1 ) != QDir::separator() ){
- formatPath.append( QDir::separator() );
- }
return formatPath;
}
@@ -917,33 +1006,41 @@
}
return true;
}
+
bool FmUtils::checkFolderFileName( const QString& name )
{
- if( name.endsWith( QChar('.'), Qt::CaseInsensitive ) ) {
+ // trim space firest, because there may be some spaces after "." , it is also not valid
+ QString trimmedName( name.trimmed() );
+ if( trimmedName.isEmpty() ) {
+ return false;
+ }
+ if( trimmedName.endsWith( QChar('.'), Qt::CaseInsensitive ) ) {
return false;
}
- if( name.contains( QChar('\\'), Qt::CaseInsensitive ) ||
- name.contains( QChar('/'), Qt::CaseInsensitive ) ||
- name.contains( QChar(':'), Qt::CaseInsensitive ) ||
- name.contains( QChar('*'), Qt::CaseInsensitive ) ||
- name.contains( QChar('?'), Qt::CaseInsensitive ) ||
- name.contains( QChar('\"'), Qt::CaseInsensitive ) ||
- name.contains( QChar('<'), Qt::CaseInsensitive ) ||
- name.contains( QChar('>'), Qt::CaseInsensitive ) ||
- name.contains( QChar('|'), Qt::CaseInsensitive ) ){
+ if( trimmedName.contains( QChar('\\'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('/'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar(':'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('*'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('?'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('\"'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('<'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('>'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('|'), Qt::CaseInsensitive ) ){
return false;
}
+ // use orignal name to exam max size of file name
if( name.length() > KMaxFileName ) {
return false;
}
return true;
}
-bool FmUtils::checkNewFolderOrFile( const QString &path, QString &errString )
+bool FmUtils::checkNewFolderOrFile( const QString &fileName, const QString &path, QString &errString )
{
+ // first check if fileName is valid, then check if path length is valid, and check if file/foler is existed at last
QFileInfo fileInfo( path );
bool ret( true );
- if (!FmUtils::checkFolderFileName( fileInfo.fileName() ) ) {
+ if (!FmUtils::checkFolderFileName( fileName ) ) {
errString = hbTrId( "Invalid file or folder name!" );
ret = false;
} else if( !FmUtils::checkMaxPathLength( path ) ) {
@@ -955,3 +1052,62 @@
}
return ret;
}
+
+/*!
+ Check if \a dest is sub level path of \a src
+ Used to check True/False when copy a folder to itself or its subfolder
+ For example, c:\data\test is sub path of c:\data.
+ But c:\data123\test is not sub path of c:\data.
+ So after got right part of path, the first char must be \ or /
+*/
+bool FmUtils::isSubLevelPath( const QString &src, const QString &dest )
+{
+ FM_LOG("FmUtils::isSubFolder: src=" + src + " dest=" + dest);
+ QString checkedSrc( FmUtils::fillPathWithSplash( src ) );
+ QString checkedDest( FmUtils::fillPathWithSplash( dest ) );
+
+ if( checkedDest.contains( checkedSrc, Qt::CaseInsensitive) &&
+ checkedDest.length() > checkedSrc.length() ) {
+ // for example c:\data\ vs c:\data\123\
+ FM_LOG("FmUtils::isSubFolder: true");
+ return true;
+ }
+ // for example c:\data\ vs c:\data\
+ // for example c:\data\ vs c:\data123\
+
+ FM_LOG("FmUtils::isSubFolder: false");
+ return false;
+}
+
+/*!
+ set the \a desFile attributes as the same with \a srcFile
+*/
+int FmUtils::setFileAttributes( const QString &srcFile, const QString &desFile )
+{
+ RFs fsSession;
+ User::LeaveIfError( fsSession.Connect() );
+ CleanupClosePushL( fsSession );
+ RFile64 src;
+ RFile64 des;
+ HBufC *buf1 = XQConversions::qStringToS60Desc( removePathSplash( formatPath( srcFile ) ) );
+ HBufC *buf2 = XQConversions::qStringToS60Desc( removePathSplash( formatPath( desFile ) ) );
+ User::LeaveIfError( src.Open( fsSession, *buf1, EFileRead | EFileShareReadersOnly ) );
+ User::LeaveIfError( des.Open( fsSession, *buf2, EFileWrite | EFileShareExclusive ) );
+ TTime mod;
+ int err = src.Modified( mod );;
+ if ( err == FmErrNone ) {
+ err = des.SetModified( mod );
+ }
+ TUint att( 0 );
+ if ( err == FmErrNone ) {
+ err = src.Att( att );
+ }
+ if ( err == FmErrNone ) {
+ des.SetAtt( att, ( ~att ) & KEntryAttMaskSupported );
+ }
+ src.Close();
+ des.Close();
+ fsSession.Close();
+ CleanupStack::PopAndDestroy(); // fsSession
+ return err;
+}
--- a/filemanager/src/inc/fmutils_win.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/inc/fmutils_win.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -222,25 +222,23 @@
Q_UNUSED( driverName );
}
+/*!
+ fill splash in the end of \a filePath if the path is not a file
+ All "/" and "\" will be changed to QDir::separator
+ \sa formatPath only changed "/" and "\" to QDir::separator
+*/
QString FmUtils::fillPathWithSplash( const QString &filePath )
{
- QString newFilePath;
+ QString newFilePath;
if( filePath.isEmpty() ) {
return newFilePath;
}
- foreach( QChar ch, filePath ) {
- if( ch == QChar('\\') || ch == QChar('/') ) {
- newFilePath.append( QDir::separator() );
- } else {
- newFilePath.append( ch );
- }
- }
+ newFilePath = formatPath( filePath );
if( newFilePath.right( 1 )!= QDir::separator() ){
newFilePath.append( QDir::separator() );
}
-
return newFilePath;
}
@@ -290,14 +288,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
@@ -437,20 +435,25 @@
return false;
}
+/*!
+ All "/" and "\" in \a path will be changed to QDir::separator
+ \sa fillPathWithSplash, fillPathWithSplash will append QDir::separator in the end if path is no a file
+*/
QString FmUtils::formatPath( const QString &path )
{
QString formatPath;
- foreach( QChar ch, path ) {
- if( ch == QChar('\\') || ch == QChar('/') ) {
- formatPath.append( QDir::separator() );
- } else {
- formatPath.append( ch );
- }
+ if( path.isEmpty() ) {
+ return formatPath;
+ }
+
+ foreach( QChar ch, path ) {
+ if( ch == QChar('\\') || ch == QChar('/') ) {
+ formatPath.append( QDir::separator() );
+ } else {
+ formatPath.append( ch );
+ }
}
- if( formatPath.right( 1 ) != QDir::separator() ){
- formatPath.append( QDir::separator() );
- }
return formatPath;
}
@@ -466,33 +469,42 @@
}
return true;
}
+
bool FmUtils::checkFolderFileName( const QString& name )
{
- if( name.endsWith( QChar('.'), Qt::CaseInsensitive ) ) {
+ // trim space firest, because there may be some spaces after "." , it is also not valid
+ // or there may only have spaces in name
+ QString trimmedName( name.trimmed() );
+ if( trimmedName.isEmpty() ) {
+ return false;
+ }
+ if( trimmedName.endsWith( QChar('.'), Qt::CaseInsensitive ) ) {
return false;
}
- if( name.contains( QChar('\\'), Qt::CaseInsensitive ) ||
- name.contains( QChar('/'), Qt::CaseInsensitive ) ||
- name.contains( QChar(':'), Qt::CaseInsensitive ) ||
- name.contains( QChar('*'), Qt::CaseInsensitive ) ||
- name.contains( QChar('?'), Qt::CaseInsensitive ) ||
- name.contains( QChar('\"'), Qt::CaseInsensitive ) ||
- name.contains( QChar('<'), Qt::CaseInsensitive ) ||
- name.contains( QChar('>'), Qt::CaseInsensitive ) ||
- name.contains( QChar('|'), Qt::CaseInsensitive ) ){
+ if( trimmedName.contains( QChar('\\'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('/'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar(':'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('*'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('?'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('\"'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('<'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('>'), Qt::CaseInsensitive ) ||
+ trimmedName.contains( QChar('|'), Qt::CaseInsensitive ) ){
return false;
}
+ // use orignal name to exam max size of file name
if( name.length() > KMaxFileName ) {
return false;
}
return true;
}
-bool FmUtils::checkNewFolderOrFile( const QString &path, QString &errString )
+bool FmUtils::checkNewFolderOrFile( const QString &fileName, const QString &path, QString &errString )
{
+ // first check if fileName is valid, then check if path length is valid, and check if file/foler is existed at last
QFileInfo fileInfo( path );
bool ret( true );
- if (!FmUtils::checkFolderFileName( fileInfo.fileName() ) ) {
+ if (!FmUtils::checkFolderFileName( fileName ) ) {
errString = hbTrId( "Invalid file or folder name, try again!" );
ret = false;
} else if( !FmUtils::checkMaxPathLength( path ) ) {
@@ -504,3 +516,42 @@
}
return ret;
}
+
+QString FmUtils::getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName )
+{
+ FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
+
+ // do not add default volume for win32 version as this is only the dummy implememnt for debug on windows
+ return driverInfo.volumeName();
+}
+
+/*!
+ Check if \a dest is sub level path of \a src
+ Used to check True/False when copy a folder to itself or its subfolder
+ For example, c:\data\test is sub path of c:\data.
+ But c:\data123\test is not sub path of c:\data.
+ So after got right part of path, the first char must be \ or /
+*/
+bool FmUtils::isSubLevelPath( const QString &src, const QString &dest )
+{
+ FM_LOG("FmUtils::isSubFolder: src=" + src + " dest=" + dest);
+ QString checkedSrc( FmUtils::fillPathWithSplash( src ) );
+ QString checkedDest( FmUtils::fillPathWithSplash( dest ) );
+
+ if( checkedDest.contains( checkedSrc, Qt::CaseInsensitive) &&
+ checkedDest.length() > checkedSrc.length() ) {
+ // for example c:\data\ vs c:\data\123\
+ FM_LOG("FmUtils::isSubFolder: true");
+ return true;
+ }
+ // for example c:\data\ vs c:\data\
+ // for example c:\data\ vs c:\data123\
+
+ FM_LOG("FmUtils::isSubFolder: false");
+ return false;
+}
+
+int FmUtils::setFileAttributes( const QString &srcFile, const QString &desFile )
+{
+ return FmErrNone;
+}