Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 5 commits
  • 24 files changed
  • 0 commit comments
  • 1 contributor
View
10 data.qrc
@@ -1,10 +0,0 @@
-<RCC>
- <qresource prefix="/qml">
- <file>main.qml</file>
- <file>FilePickerSheet.qml</file>
- <file>FileItemDelegate.qml</file>
- <file>Directory.qml</file>
- <file>DetailViewSheet.qml</file>
- <file>InputSheet.qml</file>
- </qresource>
-</RCC>
View
309 dirmodel.cpp
@@ -1,309 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#include <QDirIterator>
-#include <QDir>
-#include <QDebug>
-#include <QDateTime>
-#include <QUrl>
-
-#include <errno.h>
-#include <string.h>
-
-#include "dirmodel.h"
-#include "ioworkerthread.h"
-
-Q_GLOBAL_STATIC(IOWorkerThread, ioWorkerThread);
-
-class DirListWorker : public IORequest
-{
- Q_OBJECT
-public:
- DirListWorker(const QString &pathName)
- : mPathName(pathName)
- { }
-
- void run()
- {
- qDebug() << Q_FUNC_INFO << "Running on: " << QThread::currentThreadId();
-
- QDir tmpDir = QDir(mPathName);
- QDirIterator it(tmpDir);
- QVector<QFileInfo> directoryContents;
-
- while (it.hasNext()) {
- it.next();
-
- // skip hidden files
- if (it.fileName()[0] == QLatin1Char('.'))
- continue;
-
- directoryContents.append(it.fileInfo());
- if (directoryContents.count() >= 50) {
- emit itemsAdded(directoryContents);
-
- // clear() would force a deallocation, micro-optimisation
- directoryContents.erase(directoryContents.begin(), directoryContents.end());
- }
- }
-
- // last batch
- emit itemsAdded(directoryContents);
-
- //std::sort(directoryContents.begin(), directoryContents.end(), DirModel::fileCompare);
- }
-
-signals:
- void itemsAdded(const QVector<QFileInfo> &files);
-
-private:
- QString mPathName;
-};
-
-DirModel::DirModel(QObject *parent) : QAbstractListModel(parent)
-{
- QHash<int, QByteArray> roles = roleNames();
- roles.insert(FileNameRole, QByteArray("fileName"));
- roles.insert(CreationDateRole, QByteArray("creationDate"));
- roles.insert(ModifiedDateRole, QByteArray("modifiedDate"));
- roles.insert(FileSizeRole, QByteArray("fileSize"));
- roles.insert(IconSourceRole, QByteArray("iconSource"));
- roles.insert(FilePathRole, QByteArray("filePath"));
- roles.insert(IsDirRole, QByteArray("isDir"));
- roles.insert(IsFileRole, QByteArray("isFile"));
- setRoleNames(roles);
-
- // populate reverse mapping
- QHash<int, QByteArray>::ConstIterator it = roles.constBegin();
- for (;it != roles.constEnd(); ++it)
- mRoleMapping.insert(it.value(), it.key());
-
- // make sure we cover all roles
- Q_ASSERT(roles.count() == IsFileRole - FileNameRole);
-}
-
-QVariant DirModel::data(int row, const QByteArray &stringRole) const
-{
- QHash<QByteArray, int>::ConstIterator it = mRoleMapping.constFind(stringRole);
-
- if (it == mRoleMapping.constEnd())
- return QVariant();
-
- return data(index(row, 0), *it);
-}
-
-QVariant DirModel::data(const QModelIndex &index, int role) const
-{
- if (role < FileNameRole || role > IsFileRole) {
- qWarning() << Q_FUNC_INFO << "Got an out of range role: " << role;
- return QVariant();
- }
-
- if (index.row() < 0 || index.row() >= mDirectoryContents.count()) {
- qWarning() << "Attempted to access out of range row: " << index.row();
- return QVariant();
- }
-
- if (index.column() != 0)
- return QVariant();
-
- const QFileInfo &fi = mDirectoryContents.at(index.row());
-
- switch (role) {
- case FileNameRole:
- return fi.fileName();
- case CreationDateRole:
- return fi.created();
- case ModifiedDateRole:
- return fi.lastModified();
- case FileSizeRole: {
- qint64 kb = fi.size() / 1024;
- if (kb < 1)
- return QString::number(fi.size()) + " bytes";
- else if (kb < 1024)
- return QString::number(kb) + " kb";
-
- kb /= 1024;
- return QString::number(kb) + "mb";
- }
- case IconSourceRole: {
- const QString &fileName = fi.fileName();
-
- if (fi.isDir())
- return "image://theme/icon-m-common-directory";
-
- if (fileName.endsWith(".jpg", Qt::CaseInsensitive) ||
- fileName.endsWith(".png", Qt::CaseInsensitive)) {
- return "image://nemoThumbnail/" + fi.filePath();
- }
-
- return "image://theme/icon-m-content-document";
- }
- case FilePathRole:
- return fi.filePath();
- case IsDirRole:
- return fi.isDir();
- case IsFileRole:
- return !fi.isDir();
- default:
- // this should not happen, ever
- Q_ASSERT(false);
- qWarning() << Q_FUNC_INFO << "Got an unknown role: " << role;
- return QVariant();
- }
-}
-
-void DirModel::setPath(const QString &pathName)
-{
- qDebug() << Q_FUNC_INFO << "Changing to " << pathName << " on " << QThread::currentThreadId();
-
- beginResetModel();
- mDirectoryContents.clear();
- endResetModel();
-
- // TODO: we need to set a spinner active before we start getting results from DirListWorker
- DirListWorker *dlw = new DirListWorker(pathName);
- connect(dlw, SIGNAL(itemsAdded(QVector<QFileInfo>)), SLOT(onItemsAdded(QVector<QFileInfo>)));
- ioWorkerThread()->addRequest(dlw);
-
- mCurrentDir = pathName;
- emit pathChanged();
-}
-
-static bool fileCompare(const QFileInfo &a, const QFileInfo &b)
-{
- if (a.isDir() && !b.isDir())
- return true;
-
- if (b.isDir() && !a.isDir())
- return false;
-
- return QString::localeAwareCompare(a.fileName(), b.fileName()) < 0;
-}
-
-void DirModel::onItemsAdded(const QVector<QFileInfo> &newFiles)
-{
- // TODO: we need to perform a sorted insert
- qDebug() << Q_FUNC_INFO << "Got new files: " << newFiles.count();
-
- foreach (const QFileInfo &fi, newFiles) {
- QVector<QFileInfo>::Iterator it = qLowerBound(mDirectoryContents.begin(),
- mDirectoryContents.end(),
- fi,
- fileCompare);
-
- if (it == mDirectoryContents.end()) {
- beginInsertRows(QModelIndex(), mDirectoryContents.count(), mDirectoryContents.count());
- mDirectoryContents.append(fi);
- endInsertRows();
- } else {
- int idx = it - mDirectoryContents.begin();
- beginInsertRows(QModelIndex(), idx, idx);
- mDirectoryContents.insert(it, fi);
- endInsertRows();
- }
- }
-}
-
-void DirModel::rm(const QStringList &paths)
-{
- // TODO: handle directory deletions?
- bool error = false;
-
- foreach (const QString &path, paths) {
- error |= QFile::remove(path);
-
- if (error) {
- qWarning() << Q_FUNC_INFO << "Failed to remove " << path;
- error = false;
- }
- }
-
- // TODO: just remove removed items; don't reload the entire model
- refresh();
-}
-
-bool DirModel::rename(int row, const QString &newName)
-{
- qDebug() << Q_FUNC_INFO << "Renaming " << row << " to " << newName;
- Q_ASSERT(row >= 0 && row < mDirectoryContents.count());
- if (row < 0 || row >= mDirectoryContents.count()) {
- qWarning() << Q_FUNC_INFO << "Out of bounds access";
- return false;
- }
-
- const QFileInfo &fi = mDirectoryContents.at(row);
-
- if (!fi.isDir()) {
- QFile f(fi.absoluteFilePath());
- bool retval = f.rename(fi.absolutePath() + QDir::separator() + newName);
-
- if (!retval)
- qDebug() << Q_FUNC_INFO << "Rename returned error code: " << f.error() << f.errorString();
- else
- refresh();
- // TODO: just change the affected item... ^^
-
- return retval;
- } else {
- QDir d(fi.absoluteFilePath());
- bool retval = d.rename(fi.absoluteFilePath(), fi.absolutePath() + QDir::separator() + newName);
-
- // QDir has no way to detect what went wrong. woohoo!
-
- // TODO: just change the affected item...
- refresh();
-
- return retval;
- }
-
- // unreachable (we hope)
- Q_ASSERT(false);
- return false;
-}
-
-void DirModel::mkdir(const QString &newDir)
-{
- qDebug() << Q_FUNC_INFO << "Creating new folder " << newDir << " to " << mCurrentDir;
-
- QDir dir(mCurrentDir);
- bool retval = dir.mkdir(newDir);
- if (!retval) {
- const char *errorStr = strerror(errno);
- qDebug() << Q_FUNC_INFO << "Error creating new directory: " << errno << " (" << errorStr << ")";
- emit error("Error creating new folder", errorStr);
- } else {
- refresh();
- }
-}
-
-// for dirlistworker
-#include "dirmodel.moc"
View
103 dirmodel.h
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#ifndef DIRMODEL_H
-#define DIRMODEL_H
-
-#include <QAbstractListModel>
-#include <QFileInfo>
-#include <QVector>
-
-#include "iorequest.h"
-
-class DirModel : public QAbstractListModel
-{
- Q_OBJECT
-
- enum Roles {
- FileNameRole = Qt::UserRole,
- CreationDateRole,
- ModifiedDateRole,
- FileSizeRole,
- IconSourceRole,
- FilePathRole,
- IsDirRole,
- IsFileRole,
- };
-
-public:
- DirModel(QObject *parent = 0);
-
- int rowCount(const QModelIndex &index) const
- {
- if (index.parent() != QModelIndex())
- return 0;
-
- return mDirectoryContents.count();
- }
-
- // TODO: this won't be safe if the model can change under the holder of the row
- Q_INVOKABLE QVariant data(int row, const QByteArray &stringRole) const;
-
- QVariant data(const QModelIndex &index, int role) const;
-
- Q_INVOKABLE void refresh()
- {
- // just some syntactical sugar really
- setPath(path());
- }
-
- Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged);
- inline QString path() const { return mCurrentDir; }
-
- void setPath(const QString &pathName);
-
- Q_INVOKABLE void rm(const QStringList &paths);
-
- Q_INVOKABLE bool rename(int row, const QString &newName);
-
- Q_INVOKABLE void mkdir(const QString &newdir);
-
-public slots:
- void onItemsAdded(const QVector<QFileInfo> &newFiles);
-
-signals:
- void pathChanged();
- void error(const QString &errorTitle, const QString &errorMessage);
-
-private:
- QString mCurrentDir;
- QVector<QFileInfo> mDirectoryContents;
- QHash<QByteArray, int> mRoleMapping;
-};
-
-
-#endif // DIRMODEL_H
View
36 iorequest.cpp
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#include "iorequest.h"
-
-IORequest::IORequest() : QObject()
-{
-}
View
51 iorequest.h
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#ifndef IOREQUEST_H
-#define IOREQUEST_H
-
-#include <QObject>
-
-class IORequest : public QObject
-{
- Q_OBJECT
-public:
- explicit IORequest();
-
-public:
- virtual void run() = 0;
-
-private:
- // hide this because IORequest should *NOT* be parented directly
- using QObject::setParent;
-};
-
-#endif // IOREQUEST_H
View
92 iorequestworker.cpp
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#include <QMutexLocker>
-#include <QDebug>
-
-#include "iorequestworker.h"
-#include "iorequest.h"
-
-/*!
- Lives on an IOWorkerThread.
-
- Responsible for running IORequest jobs on the thread instance, and
- disposing of their resources once they are done.
- */
-IORequestWorker::IORequestWorker()
- : QThread()
- , mTimeToQuit(false)
-{
-}
-
-void IORequestWorker::addRequest(IORequest *request)
-{
- request->moveToThread(this);
-
- // TODO: queue requests so we run the most important one first
- QMutexLocker lock(&mMutex);
- mRequests.append(request);
-
- // wake run()
- mWaitCondition.wakeOne();
-}
-
-void IORequestWorker::run()
-{
- forever {
- QMutexLocker lock(&mMutex);
-
- if (mTimeToQuit)
- return;
-
- if (mRequests.empty())
- mWaitCondition.wait(&mMutex);
-
- while (!mRequests.isEmpty()) {
- IORequest *request = mRequests.takeFirst();
-
- lock.unlock();
-
- request->run();
- request->deleteLater();
-
- lock.relock();
- }
- }
-}
-
-void IORequestWorker::exit()
-{
- qDebug() << Q_FUNC_INFO << "Quitting";
- QMutexLocker lock(&mMutex);
- mTimeToQuit = true;
- mWaitCondition.wakeOne();
-}
View
61 iorequestworker.h
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#ifndef IOREQUESTWORKER_H
-#define IOREQUESTWORKER_H
-
-#include <QObject>
-#include <QThread>
-#include <QMutex>
-#include <QWaitCondition>
-
-#include "iorequest.h"
-
-class IORequestWorker : public QThread
-{
- Q_OBJECT
-public:
- explicit IORequestWorker();
-
- void addRequest(IORequest *request);
-
- void run();
-
- void exit();
-
-private:
- QMutex mMutex;
- QWaitCondition mWaitCondition;
- QList<IORequest *> mRequests;
- bool mTimeToQuit;
-};
-
-#endif // IOREQUESTWORKER_H
View
64 ioworkerthread.cpp
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#include "ioworkerthread.h"
-
-
-/*!
- Hosts a thread, lives on the main thread.
-
- Responsible for relaying interaction between the main thread and an IOWorkerThread.
- */
-IOWorkerThread::IOWorkerThread(QObject *parent) :
- QObject(parent)
-{
- mWorker.start(QThread::IdlePriority);
-}
-
-/*!
- Destroys an IOWorkerThread instance.
- */
-IOWorkerThread::~IOWorkerThread()
-{
- mWorker.exit();
- mWorker.wait();
-}
-
-/*!
- Attempts an asynchronous attempt to start a \a request.
-
- If the request may be run, it is queued, and true is returned, otherwise, false.
- */
-bool IOWorkerThread::addRequest(IORequest *request)
-{
- mWorker.addRequest(request);
- return true;
-}
View
52 ioworkerthread.h
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#ifndef IOWORKERTHREAD_H
-#define IOWORKERTHREAD_H
-
-#include <QObject>
-#include <QThread>
-
-#include "iorequestworker.h"
-
-class IOWorkerThread : public QObject
-{
- Q_OBJECT
-public:
- explicit IOWorkerThread(QObject *parent = 0);
- virtual ~IOWorkerThread();
- bool addRequest(IORequest *request);
-
-private:
- IORequestWorker mWorker;
-};
-
-#endif // IOWORKERTHREAD_H
View
53 qmlfilemuncher.pro
@@ -1,51 +1,2 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Wed Feb 15 16:12:09 2012
-######################################################################
-
-PROJECT_NAME = qmlfilemuncher
-QT += declarative
-TEMPLATE = app
-DEPENDPATH += .
-INCLUDEPATH += .
-
-QML_FILES = *.qml
-JS_FILES = *.js
-
-OTHER_FILES += $${QML_FILES} $${JS_FILES} \
- qtc_packaging/debian_harmattan/rules \
- qtc_packaging/debian_harmattan/README \
- qtc_packaging/debian_harmattan/manifest.aegis \
- qtc_packaging/debian_harmattan/copyright \
- qtc_packaging/debian_harmattan/control \
- qtc_packaging/debian_harmattan/compat \
- qtc_packaging/debian_harmattan/changelog
-
-target.path = $$INSTALL_ROOT/usr/bin
-INSTALLS += target
-
-icon.files = icons-Applications-filemanager.png
-icon.path = $$INSTALL_ROOT/usr/share/themes/base/meegotouch/icons
-INSTALLS += icon
-
-desktop.files = $${PROJECT_NAME}.desktop
-desktop.path = $$INSTALL_ROOT/usr/share/applications
-INSTALLS += desktop
-
-# Input
-SOURCES += main.cpp \
- ioworkerthread.cpp \
- iorequestworker.cpp \
- iorequest.cpp \
- dirmodel.cpp \
- utils.cpp
-
-RESOURCES += \
- data.qrc
-
-HEADERS += \
- ioworkerthread.h \
- iorequestworker.h \
- iorequest.h \
- dirmodel.h \
- utils.h
-
+TEMPLATE = subdirs
+SUBDIRS = src
View
10 src/data.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource>
+ <file>qml/main.qml</file>
+ <file>qml/FilePickerSheet.qml</file>
+ <file>qml/FileListDelegate.qml</file>
+ <file>qml/DirectoryPage.qml</file>
+ <file>qml/DetailViewSheet.qml</file>
+ <file>qml/InputSheet.qml</file>
+ </qresource>
+</RCC>
View
0 icons-Applications-filemanager.png → src/icons-Applications-filemanager.png
File renamed without changes
View
0 icons-Applications-filemanager.svg → src/icons-Applications-filemanager.svg
File renamed without changes.
View
5 main.cpp → src/main.cpp
@@ -40,15 +40,10 @@
#include <QThread>
#include <QMetaType>
-#include "dirmodel.h"
#include "utils.h"
-Q_DECLARE_METATYPE(QVector<QFileInfo>)
-
int main(int argc, char **argv)
{
- qRegisterMetaType<QVector<QFileInfo> >();
- qmlRegisterType<DirModel>("FBrowser", 1, 0, "DirModel");
QApplication a(argc, argv);
QDeclarativeView v;
View
0 DetailViewSheet.qml → src/qml/DetailViewSheet.qml
File renamed without changes.
View
42 Directory.qml → src/qml/DirectoryPage.qml
@@ -31,7 +31,7 @@
import QtQuick 1.1
import com.nokia.meego 1.0
-import FBrowser 1.0
+import org.nemomobile.folderlistmodel 1.0
Page {
id: page
@@ -86,31 +86,27 @@ Page {
anchors.right: page.right
clip: true
- model: DirModel {
+ model: FolderListModel {
id: dirModel
}
- delegate: FileItemDelegate {
- // TODO: can we make this more generic?
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (model.isDir)
- window.cdInto(model.filePath)
- else {
- page.selectedFilePath = model.filePath
- openFileDialog.open()
- }
+ delegate: FileListDelegate {
+ onClicked: {
+ if (model.isDir)
+ window.cdInto(model.filePath)
+ else {
+ page.selectedFilePath = model.filePath
+ openFileDialog.open()
}
+ }
- onPressAndHold: {
- page.selectedFile = model.filePath;
- page.selectedRow = model.index;
- console.log("tapping on " + page.selectedRow)
- if (tapMenu.status == DialogStatus.Closed)
- tapMenu.open()
- else
- tapMenu.close()
- }
+ onPressAndHold: {
+ page.selectedFile = model.filePath;
+ page.selectedRow = model.index;
+ console.log("tapping on " + page.selectedRow)
+ if (tapMenu.status == DialogStatus.Closed)
+ tapMenu.open()
+ else
+ tapMenu.close()
}
}
}
@@ -158,6 +154,8 @@ Page {
dirModel.rm(files)
});
deletePicker.open()
+ } else {
+ console.log("Delete Items: " + component.errorString())
}
}
}
View
15 FileItemDelegate.qml → src/qml/FileListDelegate.qml
@@ -33,12 +33,16 @@ import QtQuick 1.1
import com.nokia.meego 1.0
Rectangle {
+ id: delegate
property bool navigationMode: true
property bool selected: false
width: parent.width
height: UiConstants.ListItemHeightDefault
color: selected ? "#800000FF" : "transparent"
+ signal clicked()
+ signal pressAndHold()
+
Image {
id: icon
anchors.left: parent.left
@@ -85,5 +89,16 @@ Rectangle {
asynchronous: true
cache: true
}
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ delegate.clicked()
+ }
+
+ onPressAndHold: {
+ delegate.pressAndHold()
+ }
+ }
}
View
37 FilePickerSheet.qml → src/qml/FilePickerSheet.qml
@@ -48,34 +48,31 @@ Sheet {
ListView {
anchors.fill: parent
model: sheet.model
- delegate: FileItemDelegate {
+ delegate: FileListDelegate {
navigationMode: false
- MouseArea {
- anchors.fill: parent
- onClicked: {
- selected = !selected
+ onClicked: {
+ selected = !selected
- // TODO: inefficient (http://doc.qt.nokia.com/4.7-snapshot/qml-variant.html)
- var items = sheet.pickedPaths
+ // TODO: inefficient (http://doc.qt.nokia.com/4.7-snapshot/qml-variant.html)
+ var items = sheet.pickedPaths
- if (selected) {
- items[items.length] = model.filePath
- } else {
- for (var i = 0; i < items.length; ++i) {
- if (items[i] == model.filePath) {
+ if (selected) {
+ items[items.length] = model.filePath
+ } else {
+ for (var i = 0; i < items.length; ++i) {
+ if (items[i] == model.filePath) {
- var rest = items.slice(i + 1);
- items.length = i < 0 ? items.length + i : i;
- items = rest.concat(items)
- break;
- }
+ var rest = items.slice(i + 1);
+ items.length = i < 0 ? items.length + i : i;
+ items = rest.concat(items)
+ break;
}
}
-
- sheet.pickedPaths = items
- console.log(sheet.pickedPaths)
}
+
+ sheet.pickedPaths = items
+ console.log(sheet.pickedPaths)
}
}
}
View
0 InputSheet.qml → src/qml/InputSheet.qml
File renamed without changes.
View
4 main.qml → src/qml/main.qml
@@ -51,11 +51,13 @@ PageStackWindow {
// root should be set by a param, not by knowledge of /. that is not x-platform!
function cdInto(path, immediate)
{
- var component = Qt.createComponent("Directory.qml");
+ var component = Qt.createComponent("DirectoryPage.qml");
if (component.status == Component.Ready) {
// TODO: error handling
var dirPage = component.createObject(window, {"path": path, "isRootDirectory": path == "/" ? true : false});
pageStack.push(dirPage, {}, immediate)
+ } else {
+ console.log("cdInto: error: " + component.errorString());
}
}
}
View
0 qmlfilemuncher.desktop → src/qmlfilemuncher.desktop
File renamed without changes.
View
38 src/src.pro
@@ -0,0 +1,38 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Wed Feb 15 16:12:09 2012
+######################################################################
+
+PROJECT_NAME = qmlfilemuncher
+QT += declarative
+TEMPLATE = app
+DEPENDPATH += .
+INCLUDEPATH += .
+CONFIG -= app_bundle
+TARGET = $$PROJECT_NAME
+
+QML_FILES = *.qml
+JS_FILES = *.js
+
+OTHER_FILES += $${QML_FILES} $${JS_FILES}
+
+target.path = $$INSTALL_ROOT/usr/bin
+INSTALLS += target
+
+icon.files = icons-Applications-filemanager.png
+icon.path = $$INSTALL_ROOT/usr/share/themes/base/meegotouch/icons
+INSTALLS += icon
+
+desktop.files = $${PROJECT_NAME}.desktop
+desktop.path = $$INSTALL_ROOT/usr/share/applications
+INSTALLS += desktop
+
+# Input
+SOURCES += main.cpp \
+ utils.cpp
+
+RESOURCES += \
+ data.qrc
+
+HEADERS += \
+ utils.h
+
View
0 utils.cpp → src/utils.cpp
File renamed without changes.
View
0 utils.h → src/utils.h
File renamed without changes.

No commit comments for this range

Something went wrong with that request. Please try again.