You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2012/05/25 21:11:21 UTC
[3/3] qt commit: fixes,
moveTo dir using helper function copyFolder instead of copyDir
fixes, moveTo dir using helper function copyFolder instead of copyDir
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/commit/03d83eb4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/03d83eb4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/03d83eb4
Branch: refs/heads/master
Commit: 03d83eb48896794971827dd31232fa4b8f106404
Parents: 5361a61
Author: Longwei Su <ls...@ics.com>
Authored: Fri May 25 13:22:14 2012 -0400
Committer: Longwei Su <ls...@ics.com>
Committed: Fri May 25 13:22:14 2012 -0400
----------------------------------------------------------------------
cordovaqt.pro | 12 +++++-----
main.cpp | 2 +-
src/plugins/fileapi.cpp | 47 ++++++++++++++++++++++++++---------------
src/plugins/fileapi.h | 2 +-
4 files changed, 38 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/03d83eb4/cordovaqt.pro
----------------------------------------------------------------------
diff --git a/cordovaqt.pro b/cordovaqt.pro
index 5ec963c..bee3766 100644
--- a/cordovaqt.pro
+++ b/cordovaqt.pro
@@ -5,9 +5,8 @@
wwwDir.source = www
xmlDir.source = xml
qmlDir.source = qml
-docDir.source = doc
-DEPLOYMENTFOLDERS = wwwDir xmlDir qmlDir docDir# file1 dir1
+DEPLOYMENTFOLDERS = wwwDir xmlDir qmlDir# file1 dir1
SOURCES += main.cpp \
@@ -24,8 +23,8 @@ SOURCES += main.cpp \
src/cordova.cpp \
src/cplugin.cpp \
src/plugins/contacts.cpp \
- src/plugins/camera.cpp
- #src/plugins/media.cpp
+ src/plugins/camera.cpp
+# src/plugins/media.cpp
HEADERS += \
src/plugins/notification.h \
@@ -81,7 +80,7 @@ greaterThan(QT_MAJOR_VERSION, 4) {
symbian:TARGET.UID3 = 0xE3522943
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF
symbian:TARGET.CAPABILITY += NetworkServices UserEnvironment ReadUserData WriteUserData
- symbian:{LIBS += -lecam -lServiceHandler -lnewservice -lbafl}
+ symbian:{LIBS += -lecam -lServiceHandler -lbafl}
QT += declarative
QT += webkit
@@ -101,4 +100,5 @@ OTHER_FILES += \
qtc_packaging/debian_harmattan/control \
qtc_packaging/debian_harmattan/compat \
qtc_packaging/debian_harmattan/changelog \
- qml/main_qt4.qml
+ qml/main_qt4.qml \
+ qml/main.qml
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/03d83eb4/main.cpp
----------------------------------------------------------------------
diff --git a/main.cpp b/main.cpp
index 894bb23..0231a80 100644
--- a/main.cpp
+++ b/main.cpp
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
view->setSource(QUrl(QString("%1/qml/main_qt4.qml").arg(Cordova::instance()->workingDir())));
view->showFullScreen();
# else
- view->setSource(QUrl(QString("%1/qml/main_qt4.qml").arg(Cordova::instance()->workingDir())));
+ view->setSource(QUrl(QString("%1/qml/main.qml").arg(Cordova::instance()->workingDir())));
# if defined(Q_OS_SYMBIAN) || defined(QT_SIMULATOR)
view->showFullScreen();
# else
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/03d83eb4/src/plugins/fileapi.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.cpp b/src/plugins/fileapi.cpp
index 57f9490..e37abac 100644
--- a/src/plugins/fileapi.cpp
+++ b/src/plugins/fileapi.cpp
@@ -255,6 +255,7 @@ void FileAPI::getDirectory( int scId, int ecId, QString p_path, QVariantMap p_op
* DirectoryEntry.removeRecursively - http://www.w3.org/TR/file-system-api/#widl-DirectoryEntry-removeRecursively
*/
void FileAPI::removeRecursively( int scId, int ecId, QString p_path ) {
+ qDebug()<< Q_FUNC_INFO;
QDir dir( p_path );
if( FileAPI::rmDir(dir) ) {
this->callback( scId, "" );
@@ -511,6 +512,7 @@ void FileAPI::readAsDataURL( int scId, int ecId, QString p_path ) {
* Helper function for recursively removing a directory
*/
bool FileAPI::rmDir( QDir p_dir ) {
+ qDebug()<< Q_FUNC_INFO ;
if ( p_dir == persistentDir_){//can't remove root dir
return false;
}
@@ -592,7 +594,7 @@ void FileAPI::moveFile(int scId, int ecId,const QString& sourceFile, const QStri
}
-bool FileAPI::copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destinationParentDir, const QString& newName)
+void FileAPI::copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destinationParentDir, const QString& newName)
{
qDebug()<< Q_FUNC_INFO << sourceFolder << ", " << destinationParentDir << ", " << newName;
QDir sourceDir(sourceFolder);
@@ -605,47 +607,59 @@ bool FileAPI::copyDir(int scId, int ecId,const QString& sourceFolder, const QStr
//can't copy a dir on a file
if(QFileInfo(destFolder).isFile()){
this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" );
- return false;
+ return;
}
QDir destDir(destFolder);
//can't copy on or in itself
if( (sourceFolder == destFolder) || (sourceFolder == destinationParentDir)){
this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" );
- return false;
+ return;
}
//create the dir
if(!destDir.exists()){
qDebug() << "mkdir" << destDir.mkdir(destFolder);;
} else{
this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" );
- return false;
+ return;
}
//recursively copying begin
if(copyFolder(sourceFolder, destFolder)){
this->callback( scId, "DirectoryEntry.cast( '" + dirName + "', '" + destFolder + "' )" );
- return true;
+ return;
}else{
this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" );
- return false;
+ return;
}
}
void FileAPI::moveDir(int scId, int ecId,const QString& sourceDir, const QString& destinationParentDir, const QString& newName){
-
+ qDebug()<< Q_FUNC_INFO;
QString dirName = ((newName.isEmpty()) ? QDir(sourceDir).dirName() : newName);
QString destFolder(destinationParentDir + "/" + dirName);
QDir destDir(destFolder);
- if(destDir.exists() && (destFolder != sourceDir)){
- qDebug() << "***empty folder***";
- if(QDir(destinationParentDir).rmdir(dirName)){
- qDebug() << "rmed";
- }
+
+ //can't copy a dir on a file
+ if(QFileInfo(destFolder).isFile()){
+ this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" );
+ return;
+ }
+ //can't copy on or in itself
+ if( (sourceDir == destFolder) || (sourceDir == destinationParentDir)){
+ this->callback( ecId, "FileException.cast( FileException.INVALID_MODIFICATION_ERR )" );
+ return;
}
- if(copyDir(scId, ecId, sourceDir, destinationParentDir,newName)){
- removeRecursively(scId, ecId,sourceDir );
- this->callback( scId, "" );
+ if(destDir.exists() && (destFolder != sourceDir)){
+ if(QDir(destinationParentDir).rmdir(dirName)){
+ qDebug() << "empty folder rmed";
+ }
+ }
+ if(copyFolder(sourceDir, destFolder)){
+ qDebug() << "rming src dir if src-> dest copy success";
+ rmDir(sourceDir );
+ this->callback( scId, "DirectoryEntry.cast( '" + dirName + "', '" + destFolder + "' )" );
+ return;
} else {
qDebug()<< "unable to copy dirs" <<Q_FUNC_INFO <<
", "<<sourceDir << ", "<< destinationParentDir << ", "<<newName;
@@ -662,8 +676,7 @@ bool FileAPI::copyFolder(const QString& sourceFolder, const QString& destFolder)
if(!sourceDir.exists())
return false;
QDir destDir(destFolder);
- if(!destDir.exists())
- {
+ if(!destDir.exists()){
destDir.mkdir(destFolder);
}
QStringList files = sourceDir.entryList(QDir::Files);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/03d83eb4/src/plugins/fileapi.h
----------------------------------------------------------------------
diff --git a/src/plugins/fileapi.h b/src/plugins/fileapi.h
index 918d10d..0727772 100644
--- a/src/plugins/fileapi.h
+++ b/src/plugins/fileapi.h
@@ -49,7 +49,7 @@ public slots:
void readAsText( int scId, int ecId, QString p_path );
bool copyFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName);
void moveFile(int scId, int ecId,const QString& sourceFile, const QString& destinationParentDir, const QString& newName);
- bool copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destFolder, const QString& newName);
+ void copyDir(int scId, int ecId,const QString& sourceFolder, const QString& destFolder, const QString& newName);
void moveDir(int scId, int ecId,const QString& sourceFolder, const QString& destFolder, const QString& newName);
protected: