acceptButtonText: qsTr("Yes");
rejectButtonText: qsTr("No");
onAccepted: {
- // TODO: delete file, remove from model and move to next item
+ // TODO: Remove from model and move to next item
+ if (!remove.remove(currentItem.itemUrl)) {
+ showError(qsTr("Failed to delete item"));
+ }
+ }
+
+ DeleteHelper {
+ id: remove
}
}
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 "deletehelper.h"
+#include <QUrl>
+#include <QFile>
+#include <QDeclarativeInfo>
+
+DeleteHelper::DeleteHelper(QObject *parent) :
+ QObject(parent) {
+
+}
+
+DeleteHelper::~DeleteHelper() {
+
+}
+
+bool DeleteHelper::remove(const QUrl& path) {
+ QFile file(path.toLocalFile());
+
+ if (!file.exists()) {
+ return true;
+ }
+
+ if (!file.remove()) {
+ qmlInfo(this) << "Failed to remove file" << file.fileName() << file.errorString();
+ return false;
+ }
+
+ return true;
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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 DELETE_HELPER_H
+#define DELETE_HELPER_H
+
+#include <QObject>
+
+class QUrl;
+
+class DeleteHelper : public QObject {
+ Q_OBJECT
+
+public:
+ DeleteHelper(QObject *parent = 0);
+ ~DeleteHelper();
+
+ Q_INVOKABLE bool remove(const QUrl& path);
+};
+
+#endif /* DELETE_HELPER_H */
#include "trackerstore.h"
#include "focusrectangle.h"
#include "sharehelper.h"
+#include "deletehelper.h"
static void initQuill() {
// TODO: All these are hardcoded.
qmlRegisterType<TrackerStore>("CameraPlus", 1, 0, "TrackerStore");
qmlRegisterType<FocusRectangle>("CameraPlus", 1, 0, "FocusRectangle");
qmlRegisterType<ShareHelper>("CameraPlus", 1, 0, "ShareHelper");
+ qmlRegisterType<DeleteHelper>("CameraPlus", 1, 0, "DeleteHelper");
QUrl sourceUrl = QUrl::fromLocalFile(QDir::currentPath() + "/main.qml");
view.setSource(sourceUrl);
SOURCES += main.cpp settings.cpp filenaming.cpp quillitem.cpp displaystate.cpp fsmonitor.cpp \
cameraresources.cpp compass.cpp orientation.cpp geocode.cpp mountprotector.cpp \
- trackerstore.cpp focusrectangle.cpp sharehelper.cpp
+ trackerstore.cpp focusrectangle.cpp sharehelper.cpp deletehelper.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
+ trackerstore.h focusrectangle.h sharehelper.h deletehelper.h