File: dirprototype.cpp

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 (279 lines) | stat: -rw-r--r-- 6,263 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*
    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/>.
*/

#include "dirprototype.h"

#include "dirclass.h"

#include <QScriptEngine>

Q_DECLARE_METATYPE(DirWrapper*)
Q_DECLARE_METATYPE(ScriptableClassBase*)

DirPrototype::DirPrototype(QObject *parent)
    : QObject(parent)
{
}

QScriptValue DirPrototype::absoluteFilePath(const QScriptValue &fileName) const
{
    return thisDir().absoluteFilePath(fileName.toString());
}

QScriptValue DirPrototype::absolutePath() const
{
    return thisDir().absolutePath();
}

QScriptValue DirPrototype::canonicalPath() const
{
    return thisDir().canonicalPath();
}

bool DirPrototype::cd(const QScriptValue &dirName)
{
    return thisDir().cd(dirName.toString());
}

bool DirPrototype::cdUp()
{
    return thisDir().cdUp();
}

uint DirPrototype::count() const
{
    return thisDir().count();
}

QScriptValue DirPrototype::dirName() const
{
    return thisDir().dirName();
}

QStringList DirPrototype::entryList(const QStringList &nameFilters) const
{
    return thisDir().entryList(nameFilters);
}

bool DirPrototype::exists(const QScriptValue &name) const
{
    return thisDir().exists(name.toString());
}

bool DirPrototype::exists() const
{
    return thisDir().exists();
}

QScriptValue DirPrototype::filePath(const QScriptValue &fileName) const
{
    return thisDir().filePath(fileName.toString());
}

bool DirPrototype::isAbsolute() const
{
    return thisDir().isAbsolute();
}

bool DirPrototype::isReadable() const
{
    return thisDir().isReadable();
}

bool DirPrototype::isRelative() const
{
    return thisDir().isRelative();
}

bool DirPrototype::isRoot() const
{
    return thisDir().isRoot();
}

bool DirPrototype::makeAbsolute()
{
    return thisDir().makeAbsolute();
}

bool DirPrototype::mkdir(const QScriptValue &dirName) const
{
    return thisDir().mkdir(dirName.toString());
}

bool DirPrototype::mkpath(const QScriptValue &dirPath) const
{
    return thisDir().mkpath(dirPath.toString());
}

QStringList DirPrototype::nameFilters() const
{
    return thisDir().nameFilters();
}

QScriptValue DirPrototype::path() const
{
    return thisDir().path();
}

void DirPrototype::refresh() const
{
    thisDir().refresh();
}

QScriptValue DirPrototype::relativeFilePath(const QScriptValue &fileName) const
{
    return thisDir().relativeFilePath(fileName.toString());
}

bool DirPrototype::remove(const QScriptValue &fileName)
{
    return thisDir().remove(fileName.toString());
}

bool DirPrototype::rename(const QScriptValue &oldName, const QScriptValue &newName)
{
    return thisDir().rename(oldName.toString(), newName.toString());
}

bool DirPrototype::rmdir(const QScriptValue &dirName) const
{
    return thisDir().rmdir(dirName.toString());
}

bool DirPrototype::rmpath(const QScriptValue &dirPath) const
{
    return thisDir().rmpath(dirPath.toString());
}

void DirPrototype::setNameFilters(const QStringList &nameFilters)
{
    thisDir().setNameFilters(nameFilters);
}

void DirPrototype::setPath(const QScriptValue &path)
{
    thisDir().setPath(path.toString());
}

void DirPrototype::addSearchPath(const QScriptValue &prefix, const QScriptValue &path) const
{
    QDir::addSearchPath(prefix.toString(), path.toString());
}

QScriptValue DirPrototype::cleanPath(const QScriptValue &path) const
{
    return QDir::cleanPath(path.toString());
}

QScriptValue DirPrototype::currentPath() const
{
    return QDir::currentPath();
}

QScriptValue DirPrototype::fromNativeSeparators(const QScriptValue &pathName) const
{
    return QDir::fromNativeSeparators(pathName.toString());
}

QScriptValue DirPrototype::home() const
{
    return newDir(QDir::home());
}

QScriptValue DirPrototype::homePath() const
{
    return QDir::homePath();
}

bool DirPrototype::isAbsolutePath(const QScriptValue &path) const
{
    return QDir::isAbsolutePath(path.toString());
}

bool DirPrototype::isRelativePath(const QScriptValue &path) const
{
    return QDir::isRelativePath(path.toString());
}

bool DirPrototype::match(const QScriptValue &filter, const QScriptValue &fileName) const
{
    return QDir::match(filter.toString(), fileName.toString());
}

bool DirPrototype::match(const QStringList &filters, const QScriptValue &fileName) const
{
    return QDir::match(filters, fileName.toString());
}

QScriptValue DirPrototype::root() const
{
    return newDir(QDir::root());
}

QScriptValue DirPrototype::rootPath() const
{
    return QDir::rootPath();
}

QStringList DirPrototype::searchPaths(const QScriptValue &prefix) const
{
    return QDir::searchPaths(prefix.toString());
}

QScriptValue DirPrototype::separator() const
{
    return QString(QDir::separator());
}

bool DirPrototype::setCurrent(const QScriptValue &path) const
{
    return QDir::setCurrent(path.toString());
}

void DirPrototype::setSearchPaths(const QScriptValue &prefix, const QStringList &searchPaths) const
{
    QDir::setSearchPaths(prefix.toString(), searchPaths);
}

QScriptValue DirPrototype::temp() const
{
    return newDir(QDir::temp());
}

QScriptValue DirPrototype::tempPath() const
{
    return QDir::tempPath();
}

QScriptValue DirPrototype::toNativeSeparators(const QScriptValue &pathName) const
{
    return QDir::toNativeSeparators(pathName.toString());
}

QDir &DirPrototype::thisDir() const
{
    return qscriptvalue_cast<DirWrapper*>(thisObject().data())->dir();
}

QScriptValue DirPrototype::newDir(const QDir &dir) const
{
    QScriptValue ctor = engine()->globalObject().property("Dir");
    ScriptableClassBase *cls = qscriptvalue_cast<ScriptableClassBase*>(ctor.data());
    return cls ? cls->newInstance(new DirWrapper(dir)) : QScriptValue();
}