First attempt at removing QtQuick 1.1 hardcoding from qml files.
authorMohammed Sameer <msameer@foolab.org>
Mon, 22 Jul 2013 17:35:11 +0000 (20:35 +0300)
committerMohammed Sameer <msameer@foolab.org>
Mon, 22 Jul 2013 17:35:11 +0000 (20:35 +0300)
We replace QtQuick import with a macro which will get replaced during runtime
with the correct version via a custom QFileSystemEngine subclass

46 files changed:
qml/CameraOverlay.qml
qml/CameraSettings.qml
qml/CameraToolBar.qml
qml/CameraView.qml
qml/CaptureButton.qml
qml/CheckButton.qml
qml/FlashButton.qml
qml/FocusReticle.qml
qml/ImageColorFilterButton.qml
qml/ImageEvCompButton.qml
qml/ImageIsoButton.qml
qml/ImageOverlay.qml
qml/ImageResolutionSettings.qml
qml/ImageSceneButton.qml
qml/ImageSettings.qml
qml/ImageWhiteBalanceButton.qml
qml/Indicator.qml
qml/ModeButton.qml
qml/ModeController.qml
qml/PipelineManager.qml
qml/PostCaptureItem.qml
qml/PostCaptureView.qml
qml/PreviewImage.qml
qml/RecordingDurationLabel.qml
qml/SectionHeader.qml
qml/SettingsView.qml
qml/Standby.qml
qml/TextSwitch.qml
qml/VideoColorFilterButton.qml
qml/VideoEvCompButton.qml
qml/VideoMuteButton.qml
qml/VideoOverlay.qml
qml/VideoPlayerPage.qml
qml/VideoResolutionSettings.qml
qml/VideoSceneButton.qml
qml/VideoSettings.qml
qml/VideoTorchButton.qml
qml/VideoWhiteBalanceButton.qml
qml/ZoomCaptureButton.qml
qml/ZoomCaptureCancel.qml
qml/ZoomSlider.qml
qml/main.qml
src/main.cpp
src/qmlfileengine.cpp [new file with mode: 0644]
src/qmlfileengine.h [new file with mode: 0644]
src/src.pro

index 88b0849..9f10d41 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import CameraPlus 1.0
index e2bf74d..9a67ba1 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 Column {
index b5f61b9..c0e5366 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import "CameraToolBar.js" as Layout
 
index 8ce012e..d68c4e2 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import QtCamera 1.0
 import CameraPlus 1.0
 
index 38e1f0e..6dc99a3 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 Item {
index 573a301..8aa8eb0 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 ToolIcon {
index 2f5497b..bf6cc51 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index 82d267b..c086ec7 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import QtCamera 1.0
 import CameraPlus 1.0
 
index 75680dd..c28a54e 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index 1abcb82..0a12cf7 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index b916be0..7cccff7 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index 842768d..9875ab4 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import CameraPlus 1.0
index bfd1309..3c78458 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 Column {
index 5cae56c..226be62 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index bfd862a..220f226 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index 6d60392..55290e9 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index 873ac22..da59619 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 
 Image {
         anchors.left: parent.left
index 31a19cf..0063e7e 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import QtCamera 1.0
 
 CaptureButton {
index a986dd7..b9c8b8a 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index d328711..04294ba 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import QtCamera 1.0
 import CameraPlus 1.0
 
index 5e5b79e..f9c4a85 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import CameraPlus 1.0
 
index 7130f5b..a1c0e06 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import CameraPlus 1.0
 import com.nokia.meego 1.1
 import QtCamera 1.0
index e70509e..52a32f3 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index ffac09a..8ab644c 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 Rectangle {
index ae39e4d..51f6ee3 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 Row {
index 41b8773..40ac8fd 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import QtCamera 1.0
 import CameraPlus 1.0
 
index ed5eb92..471a099 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.0
 
 Rectangle {
index 2744d17..74e042b 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 Item {
index 886d2ab..cf864d6 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index c46f24b..b012c17 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index 7df6aa6..ada6812 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 ToolIcon {
index 91f9e1a..735833d 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import CameraPlus 1.0
index 6820030..dbe7274 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import CameraPlus 1.0
 import QtCamera 1.0
index e80be20..718ee7d 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 
 Column {
index d87d483..96e6fd1 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index c7a554a..e0f90fd 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index 34f42d2..e813ac6 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index 33ab5eb..353619b 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 import "data.js" as Data
index 7b2763e..ed10da3 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import CameraPlus 1.0
 
index d89ee04..b85966a 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import CameraPlus 1.0
 
index dc5dbc8..13609f0 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import QtCamera 1.0
 
index e04dadc..6676ff6 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+@IMPORT_QT_QUICK@
 import com.nokia.meego 1.1
 import com.nokia.extras 1.1
 import QtCamera 1.0
index 9f83baa..7f9758b 100644 (file)
 #include "qt_private/qdeclarativedebughelper_p.h"
 #endif /* QMLJSDEBUGGER */
 
+#include <QAbstractFileEngineHandler>
+#include "qmlfileengine.h"
+
+class QmlFileEngineHandler : public QAbstractFileEngineHandler {
+  QAbstractFileEngine *create(const QString& fileName) const {
+    QString fn = fileName.toLower();
+    if (fn.startsWith(':') && fn.endsWith(".qml")) {
+      return new QmlFileEngine(fileName);
+    }
+
+    return 0;
+  }
+};
+
 Q_DECL_EXPORT int main(int argc, char *argv[]) {
   QApplication::setAttribute(Qt::AA_X11InitThreads, true);
   QApplication app(argc, argv);
 
+  QmlFileEngineHandler handler;
+  Q_UNUSED(handler);
+
 #ifdef QMLJSDEBUGGER
   QDeclarativeDebugHelper::enableDebugging();
 #endif /* QMLJSDEBUGGER */
diff --git a/src/qmlfileengine.cpp b/src/qmlfileengine.cpp
new file mode 100644 (file)
index 0000000..e9262b7
--- /dev/null
@@ -0,0 +1,225 @@
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "qmlfileengine.h"
+#include <QResource>
+#include <QDateTime>
+
+// TODO: support mmap extension
+
+QmlFileEngine::QmlFileEngine(const QString& fileName) :
+  QFSFileEngine(fileName),
+  m_res(new QResource(fileName)),
+  m_off(0) {
+
+}
+
+void QmlFileEngine::setFileName(const QString& file) {
+  m_res->setFileName(file);
+}
+
+bool QmlFileEngine::open(QIODevice::OpenMode flags) {
+  if (!m_res->isValid() || m_res->fileName().isEmpty()) {
+    return false;
+  }
+
+  if (flags & QIODevice::WriteOnly) {
+    return false;
+  }
+
+  m_off = 0;
+
+  if (m_res->isCompressed()) {
+    m_data = qUncompress(m_res->data(), m_res->size());
+  }
+  else {
+    m_data = QByteArray::fromRawData((const char *)m_res->data(), m_res->size());
+  }
+
+  m_data.replace("@IMPORT_QT_QUICK@", "import QtQuick 1.1");
+
+  return true;
+}
+
+bool QmlFileEngine::close() {
+  m_data.clear();
+  m_off = 0;
+
+  return true;
+}
+
+bool QmlFileEngine::flush() {
+  return true;
+}
+
+qint64 QmlFileEngine::size() const {
+  return m_data.size();
+}
+
+qint64 QmlFileEngine::pos() const {
+  return m_off;
+}
+
+bool QmlFileEngine::atEnd() const {
+  return m_off == m_data.size();
+}
+
+bool QmlFileEngine::seek(qint64 pos) {
+  if (pos > m_data.size()) {
+    return false;
+  }
+
+  return true;
+}
+
+qint64 QmlFileEngine::read(char *data, qint64 len) {
+  if (len > m_data.size() - m_off) {
+    len = m_data.size() - m_off;
+  }
+
+  if (len <= 0) {
+    return 0;
+  }
+
+  memcpy(data, m_data.data() + m_off, len);
+
+  m_off += len;
+
+  return len;
+}
+
+qint64 QmlFileEngine::write(const char *data, qint64 len) {
+  Q_UNUSED(data);
+  Q_UNUSED(len);
+
+  return false;
+}
+
+bool QmlFileEngine::remove() {
+  return false;
+}
+
+bool QmlFileEngine::copy(const QString& newName) {
+  Q_UNUSED(newName);
+
+  return false;
+}
+
+bool QmlFileEngine::rename(const QString& newName) {
+  Q_UNUSED(newName);
+
+  return false;
+}
+
+bool QmlFileEngine::link(const QString& newName) {
+  Q_UNUSED(newName);
+
+  return false;
+}
+
+bool QmlFileEngine::isSequential() const {
+  return false;
+}
+
+bool QmlFileEngine::isRelativePath() const {
+  return false;
+}
+
+bool QmlFileEngine::mkdir(const QString& dirName, bool createParentDirectories) const {
+  Q_UNUSED(dirName);
+  Q_UNUSED(createParentDirectories);
+
+  return false;
+}
+
+bool QmlFileEngine::rmdir(const QString& dirName, bool recurseParentDirectories) const {
+  Q_UNUSED(dirName);
+  Q_UNUSED(recurseParentDirectories);
+
+  return false;
+}
+
+bool QmlFileEngine::setSize(qint64 size) {
+  Q_UNUSED(size);
+
+  return false;
+}
+
+QStringList QmlFileEngine::entryList(QDir::Filters filters, const QStringList& filterNames) const {
+  Q_UNUSED(filters);
+  Q_UNUSED(filterNames);
+
+  return QStringList();
+}
+
+bool QmlFileEngine::caseSensitive() const {
+  return true;
+}
+
+QFSFileEngine::FileFlags QmlFileEngine::fileFlags(FileFlags type) const {
+  QFSFileEngine::FileFlags flags = 0;
+
+  if (!m_res->isValid()) {
+    return flags;
+  }
+
+  if (type & TypesMask) {
+    flags |= FileType;
+  }
+
+  if (type & FlagsMask) {
+    flags |= ExistsFlag;
+  }
+
+  return flags;
+}
+
+bool QmlFileEngine::setPermissions(uint perms) {
+  Q_UNUSED(perms);
+
+  return false;
+}
+
+QString QmlFileEngine::fileName(QAbstractFileEngine::FileName file) const {
+  Q_UNUSED(file);
+
+  // TODO:
+  return QString();
+}
+
+uint QmlFileEngine::ownerId(FileOwner owner) const {
+  Q_UNUSED(owner);
+
+  return -2;
+}
+
+QString QmlFileEngine::owner(FileOwner owner) const {
+  Q_UNUSED(owner);
+
+  return QString();
+}
+
+QDateTime QmlFileEngine::fileTime(FileTime time) const {
+  Q_UNUSED(time);
+
+  return QDateTime();
+}
diff --git a/src/qmlfileengine.h b/src/qmlfileengine.h
new file mode 100644 (file)
index 0000000..fc7e463
--- /dev/null
@@ -0,0 +1,73 @@
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef QML_FILE_ENGINE_H
+#define QML_FILE_ENGINE_H
+
+#include <QFSFileEngine>
+
+class QResource;
+
+class QmlFileEngine : public QFSFileEngine {
+public:
+  QmlFileEngine(const QString& fileName);
+
+  virtual void setFileName(const QString& file);
+  virtual bool open(QIODevice::OpenMode flags);
+  virtual bool close();
+  virtual bool flush();
+  virtual qint64 size() const;
+  virtual qint64 pos() const;
+  virtual bool atEnd() const;
+  virtual bool seek(qint64 pos);
+  virtual qint64 read(char *data, qint64 len);
+  virtual qint64 write(const char *data, qint64 len);
+  virtual bool remove();
+  virtual bool copy(const QString& newName);
+  virtual bool rename(const QString& newName);
+  virtual bool link(const QString& newName);
+  virtual bool isSequential() const;
+  virtual bool isRelativePath() const;
+  virtual bool mkdir(const QString& dirName, bool createParentDirectories) const;
+  virtual bool rmdir(const QString& dirName, bool recurseParentDirectories) const;
+  virtual bool setSize(qint64 size);
+  virtual QStringList entryList(QDir::Filters filters, const QStringList& filterNames) const;
+  virtual bool caseSensitive() const;
+  virtual FileFlags fileFlags(FileFlags type) const;
+  virtual bool setPermissions(uint perms);
+  virtual QString fileName(QAbstractFileEngine::FileName file) const;
+  virtual uint ownerId(FileOwner owner) const;
+  virtual QString owner(FileOwner owner) const;
+  virtual QDateTime fileTime(FileTime time) const;
+  // TODO:
+  //  virtual Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames);
+  //  virtual Iterator *endEntryList();
+  //  bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
+  //  bool supportsExtension(Extension extension) const;
+
+private:
+  QResource *m_res;
+  QByteArray m_data;
+  qint64 m_off;
+};
+
+#endif /* QML_FILE_ENGINE_H */
index ababc84..036e8d8 100644 (file)
@@ -15,13 +15,13 @@ SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp displaystate.cpp f
            cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
            trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.cpp galleryhelper.cpp \
            postcapturemodel.cpp batteryinfo.cpp gridlines.cpp deviceinfo.cpp devicekeys.cpp \
-           platformsettings.cpp dbusservice.cpp
+           platformsettings.cpp dbusservice.cpp qmlfileengine.cpp
 
 HEADERS += settings.h filenaming.h quillitem.h displaystate.h fsmonitor.h \
            cameraresources.h compass.h orientation.h geocode.h mountprotector.h \
            trackerstore.h focusrectangle.h sharehelper.h deletehelper.h galleryhelper.h \
            postcapturemodel.h batteryinfo.h gridlines.h deviceinfo.h devicekeys.h \
-           platformsettings.h dbusservice.h
+           platformsettings.h dbusservice.h qmlfileengine.h
 
 RESOURCES += ../qml/qml.qrc