File: dirprototype.h

package info (click to toggle)
copyq 3.7.3-1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 10,480 kB
  • sloc: cpp: 51,894; sh: 734; python: 211; xml: 57; makefile: 34
file content (101 lines) | stat: -rw-r--r-- 3,621 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
    Copyright (c) 2018, Lukas Holecek <hluk@email.cz>

    This file is part of CopyQ.

    CopyQ is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    CopyQ 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with CopyQ.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DIRPROTOTYPE_H
#define DIRPROTOTYPE_H

#include <QDir>
#include <QObject>
#include <QScriptable>
#include <QScriptValue>

class DirWrapper : public QObject {
    Q_OBJECT
public:
    explicit DirWrapper(const QString &path) : m_dir(path) {}
    explicit DirWrapper(const QDir &dir) : m_dir(dir) {}

    QDir &dir() { return m_dir; }
private:
    QDir m_dir;
};

class DirPrototype : public QObject, public QScriptable
{
    Q_OBJECT
public:
    explicit DirPrototype(QObject *parent = nullptr);

public slots:
    QScriptValue absoluteFilePath(const QScriptValue &fileName) const;
    QScriptValue absolutePath() const;
    QScriptValue canonicalPath() const;
    bool cd(const QScriptValue &dirName);
    bool cdUp();
    uint count() const;
    QScriptValue dirName() const;
    QStringList entryList(const QStringList &nameFilters = QStringList()) const;
    bool exists(const QScriptValue &name) const;
    bool exists() const;
    QScriptValue filePath(const QScriptValue &fileName) const;
    bool isAbsolute() const;
    bool isReadable() const;
    bool isRelative() const;
    bool isRoot() const;
    bool makeAbsolute();
    bool mkdir(const QScriptValue &dirName) const;
    bool mkpath(const QScriptValue &dirPath) const;
    QStringList nameFilters() const;
    QScriptValue path() const;
    void refresh() const;
    QScriptValue relativeFilePath(const QScriptValue &fileName) const;
    bool remove(const QScriptValue &fileName);
    bool rename(const QScriptValue &oldName, const QScriptValue &newName);
    bool rmdir(const QScriptValue &dirName) const;
    bool rmpath(const QScriptValue &dirPath) const;
    void setNameFilters(const QStringList &nameFilters);
    void setPath(const QScriptValue &path);

    void addSearchPath(const QScriptValue &prefix, const QScriptValue &path) const;
    QScriptValue cleanPath(const QScriptValue &path) const;
    QScriptValue currentPath() const;
    QScriptValue fromNativeSeparators(const QScriptValue &pathName) const;
    QScriptValue home() const;
    QScriptValue homePath() const;
    bool isAbsolutePath(const QScriptValue &path) const;
    bool isRelativePath(const QScriptValue &path) const;
    bool match(const QScriptValue &filter, const QScriptValue &fileName) const;
    bool match(const QStringList &filters, const QScriptValue &fileName) const;
    QScriptValue root() const;
    QScriptValue rootPath() const;
    QStringList searchPaths(const QScriptValue &prefix) const;
    QScriptValue separator() const;
    bool setCurrent(const QScriptValue &path) const;
    void setSearchPaths(const QScriptValue &prefix, const QStringList &searchPaths) const;
    QScriptValue temp() const;
    QScriptValue tempPath() const;
    QScriptValue toNativeSeparators(const QScriptValue &pathName) const;

private:
    QDir &thisDir() const;

    QScriptValue newDir(const QDir &dir) const;
};

#endif // DIRPROTOTYPE_H