|
|
4c75f9e |
/*
|
|
|
4c75f9e |
Copyright (c) 2017, Lukas Holecek <hluk@email.cz>
|
|
|
4c75f9e |
|
|
|
4c75f9e |
This file is part of CopyQ.
|
|
|
4c75f9e |
|
|
|
4c75f9e |
CopyQ is free software: you can redistribute it and/or modify
|
|
|
4c75f9e |
it under the terms of the GNU General Public License as published by
|
|
|
4c75f9e |
the Free Software Foundation, either version 3 of the License, or
|
|
|
4c75f9e |
(at your option) any later version.
|
|
|
4c75f9e |
|
|
|
4c75f9e |
CopyQ is distributed in the hope that it will be useful,
|
|
|
4c75f9e |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c75f9e |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
4c75f9e |
GNU General Public License for more details.
|
|
|
4c75f9e |
|
|
|
4c75f9e |
You should have received a copy of the GNU General Public License
|
|
|
4c75f9e |
along with CopyQ. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
|
|
|
4c75f9e |
#ifndef DIRPROTOTYPE_H
|
|
|
4c75f9e |
#define DIRPROTOTYPE_H
|
|
|
4c75f9e |
|
|
|
4c75f9e |
#include <QDir>
|
|
|
4c75f9e |
#include <QObject>
|
|
|
4c75f9e |
#include <QScriptable>
|
|
|
4c75f9e |
#include <QScriptValue>
|
|
|
4c75f9e |
|
|
|
4c75f9e |
class DirWrapper : public QObject {
|
|
|
4c75f9e |
Q_OBJECT
|
|
|
4c75f9e |
public:
|
|
|
4c75f9e |
explicit DirWrapper(const QString &path) : m_dir(path) {}
|
|
|
4c75f9e |
explicit DirWrapper(const QDir &dir) : m_dir(dir) {}
|
|
|
4c75f9e |
|
|
|
4c75f9e |
QDir &dir() { return m_dir; }
|
|
|
4c75f9e |
private:
|
|
|
4c75f9e |
QDir m_dir;
|
|
|
4c75f9e |
};
|
|
|
4c75f9e |
|
|
|
4c75f9e |
class DirPrototype : public QObject, public QScriptable
|
|
|
4c75f9e |
{
|
|
|
4c75f9e |
Q_OBJECT
|
|
|
4c75f9e |
public:
|
|
|
4c75f9e |
explicit DirPrototype(QObject *parent = nullptr);
|
|
|
4c75f9e |
|
|
|
4c75f9e |
public slots:
|
|
|
4c75f9e |
QScriptValue absoluteFilePath(const QScriptValue &fileName) const;
|
|
|
4c75f9e |
QScriptValue absolutePath() const;
|
|
|
4c75f9e |
QScriptValue canonicalPath() const;
|
|
|
4c75f9e |
bool cd(const QScriptValue &dirName);
|
|
|
4c75f9e |
bool cdUp();
|
|
|
4c75f9e |
uint count() const;
|
|
|
4c75f9e |
QScriptValue dirName() const;
|
|
|
4c75f9e |
QStringList entryList(const QStringList &nameFilters = QStringList()) const;
|
|
|
4c75f9e |
bool exists(const QScriptValue &name) const;
|
|
|
4c75f9e |
bool exists() const;
|
|
|
4c75f9e |
QScriptValue filePath(const QScriptValue &fileName) const;
|
|
|
4c75f9e |
bool isAbsolute() const;
|
|
|
4c75f9e |
bool isReadable() const;
|
|
|
4c75f9e |
bool isRelative() const;
|
|
|
4c75f9e |
bool isRoot() const;
|
|
|
4c75f9e |
bool makeAbsolute();
|
|
|
4c75f9e |
bool mkdir(const QScriptValue &dirName) const;
|
|
|
4c75f9e |
bool mkpath(const QScriptValue &dirPath) const;
|
|
|
4c75f9e |
QStringList nameFilters() const;
|
|
|
4c75f9e |
QScriptValue path() const;
|
|
|
4c75f9e |
void refresh() const;
|
|
|
4c75f9e |
QScriptValue relativeFilePath(const QScriptValue &fileName) const;
|
|
|
4c75f9e |
bool remove(const QScriptValue &fileName);
|
|
|
4c75f9e |
bool rename(const QScriptValue &oldName, const QScriptValue &newName);
|
|
|
4c75f9e |
bool rmdir(const QScriptValue &dirName) const;
|
|
|
4c75f9e |
bool rmpath(const QScriptValue &dirPath) const;
|
|
|
4c75f9e |
void setNameFilters(const QStringList &nameFilters);
|
|
|
4c75f9e |
void setPath(const QScriptValue &path);
|
|
|
4c75f9e |
|
|
|
4c75f9e |
void addSearchPath(const QScriptValue &prefix, const QScriptValue &path) const;
|
|
|
4c75f9e |
QScriptValue cleanPath(const QScriptValue &path) const;
|
|
|
4c75f9e |
QScriptValue currentPath() const;
|
|
|
4c75f9e |
QScriptValue fromNativeSeparators(const QScriptValue &pathName) const;
|
|
|
4c75f9e |
QScriptValue home() const;
|
|
|
4c75f9e |
QScriptValue homePath() const;
|
|
|
4c75f9e |
bool isAbsolutePath(const QScriptValue &path) const;
|
|
|
4c75f9e |
bool isRelativePath(const QScriptValue &path) const;
|
|
|
4c75f9e |
bool match(const QScriptValue &filter, const QScriptValue &fileName) const;
|
|
|
4c75f9e |
bool match(const QStringList &filters, const QScriptValue &fileName) const;
|
|
|
4c75f9e |
QScriptValue root() const;
|
|
|
4c75f9e |
QScriptValue rootPath() const;
|
|
|
4c75f9e |
QStringList searchPaths(const QScriptValue &prefix) const;
|
|
|
4c75f9e |
QChar separator() const;
|
|
|
4c75f9e |
bool setCurrent(const QScriptValue &path) const;
|
|
|
4c75f9e |
void setSearchPaths(const QScriptValue &prefix, const QStringList &searchPaths) const;
|
|
|
4c75f9e |
QScriptValue temp() const;
|
|
|
4c75f9e |
QScriptValue tempPath() const;
|
|
|
4c75f9e |
QScriptValue toNativeSeparators(const QScriptValue &pathName) const;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
private:
|
|
|
4c75f9e |
QDir &thisDir() const;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
QScriptValue newDir(const QDir &dir) const;
|
|
|
4c75f9e |
};
|
|
|
4c75f9e |
|
|
|
4c75f9e |
#endif // DIRPROTOTYPE_H
|