From 776a9aeaa8006e789d3f956250876867c350a209 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 13:23:38 +0000 Subject: Added a file handle to QFileOpenEvent on Symbian QFileOpenEvent needs to tell the recipient what file to open. Normally that is by filename. But on Symbian, some files can only be opened from an already-open file handle that has been passed in. For example data caged files in c:\private or z:\sys. So QFileOpenEvent needs to be able to hold a Symbian file handle so that the recipient can access any file requested of it. Coming soon... a method by which the reciever can access the file without knowing about all this messy file handle stuff going on behind the scenes. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.cpp | 28 ++++++++++++++++++++++++++-- src/gui/kernel/qevent.h | 7 +++++++ src/gui/kernel/qevent_p.h | 7 +++++++ src/gui/s60framework/qs60maindocument.cpp | 17 ++++++----------- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index e7abb47..f7bc54c 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -53,6 +53,10 @@ #include "qgesture.h" #include "qgesture_p.h" +#ifdef Q_OS_SYMBIAN +#include "private/qcore_symbian_p.h" +#endif + QT_BEGIN_NAMESPACE /*! @@ -3023,7 +3027,7 @@ QShowEvent::~QShowEvent() This event is only used to notify the application of a request. It may be safely ignored. - \note This class is currently supported for Mac OS X only. + \note This class is currently supported for Mac OS X and Symbian only. */ /*! @@ -3049,11 +3053,31 @@ QFileOpenEvent::QFileOpenEvent(const QUrl &url) f = url.toLocalFile(); } +#ifdef Q_OS_SYMBIAN +/*! \internal +*/ +QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle) + : QEvent(FileOpen) +{ + TFileName fullName; + fileHandle.FullName(fullName); + QString file = qt_TDesC2QString(fullName); + f = file; + QScopedPointer priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(file))); + qt_symbian_throwIfError(priv->file.Duplicate(fileHandle)); + d = reinterpret_cast(priv.take()); +} +#endif + /*! \internal */ QFileOpenEvent::~QFileOpenEvent() { - delete reinterpret_cast(d); + QFileOpenEventPrivate *priv = reinterpret_cast(d); +#ifdef Q_OS_SYMBIAN + priv->file.Close(); +#endif + delete priv; } /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index a7b06f4..2f5c486 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -55,6 +55,10 @@ #include #include +#ifdef Q_OS_SYMBIAN +class RFile; +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -641,6 +645,9 @@ class Q_GUI_EXPORT QFileOpenEvent : public QEvent public: QFileOpenEvent(const QString &file); QFileOpenEvent(const QUrl &url); +#ifdef Q_OS_SYMBIAN + QFileOpenEvent(const RFile &fileHandle); +#endif ~QFileOpenEvent(); inline QString file() const { return f; } diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 3a27023..01af384 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -46,6 +46,10 @@ #include #include +#ifdef Q_OS_SYMBIAN +#include +#endif + QT_BEGIN_NAMESPACE // @@ -176,6 +180,9 @@ public: } QUrl url; +#ifdef Q_OS_SYMBIAN + RFile file; +#endif }; diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index 95effbc..eafbcb0 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -111,14 +111,12 @@ CEikAppUi *QS60MainDocument::CreateAppUiL() /*! \internal */ -CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &/*aFs*/) +CFileStore *QS60MainDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC &aFilename, RFs &/*aFs*/) { - if (aDoOpen) { - QCoreApplication* app = QCoreApplication::instance(); - QString qname = qt_TDesC2QString(aFilename); - QFileOpenEvent* event = new QFileOpenEvent(qname); - app->postEvent(app, event); - } + QCoreApplication* app = QCoreApplication::instance(); + QString qname = qt_TDesC2QString(aFilename); + QFileOpenEvent* event = new QFileOpenEvent(qname); + app->postEvent(app, event); return 0; } @@ -128,10 +126,7 @@ CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, R void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { QCoreApplication* app = QCoreApplication::instance(); - TFileName name; - aFile.FullName(name); - QString qname = qt_TDesC2QString(name); - QFileOpenEvent* event = new QFileOpenEvent(qname); + QFileOpenEvent* event = new QFileOpenEvent(aFile); app->postEvent(app, event); aFileStore = 0; } -- cgit v0.12