WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZFileInfo.h
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2013, 2014 Bob Dinitto
4  *
5  * ZFileInfo.h
6  *
7  * Project: bitumen
8  * Created: Jan 13, 2012
9  * Author: Bob Dinitto
10  *
11  * Zuble is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  *
25  */
26 
27 #ifndef ZFILEINFO_H_
28 #define ZFILEINFO_H_
29 
30 #include "zblcore_global.h"
31 #include "zglobal.h"
32 #include "ZblException.h"
33 
34 #include <QObject>
35 #include <QFileInfo>
36 #include <QVariant>
37 
38 namespace Zbl
39 {
40 
48 class ZBLCORESHARED_EXPORT ZFileInfo: public QObject
49 {
50  friend class ZDir;
51 
52  Q_OBJECT
53 
54 public:
55  explicit ZFileInfo(QObject *parent = 0);
56  virtual ~ZFileInfo();
57 
58  void setInfoList(QFileInfoList infoList);
59 
60  // properties that affect the whole list
61 
62  Q_PROPERTY(int count READ count)
63  Q_PROPERTY(int index READ getIndex WRITE setIndex)
64 
65  int count();
66  int getIndex();
67  void setIndex(int index);
68 
69  // properties that affect only the currently selected QFileInfo object
70 
71  Z_PROPGET_DEF(absoluteFilePath, QString)
72  Z_PROPGET_DEF(canonicalFilePath, QString)
73  Z_PROPGET_DEF(baseName, QString)
74  Z_PROPGET_DEF(completeBaseName, QString)
75  Z_PROPGET_DEF(suffix, QString)
76  Z_PROPGET_DEF(bundleName, QString)
77  Z_PROPGET_DEF(completeSuffix, QString)
78  Z_PROPGET_DEF(path, QString)
79  Z_PROPGET_DEF(absolutePath, QString)
80  Z_PROPGET_DEF(canonicalPath, QString)
81  Z_PROPGET_DEF(filePath, QString)
82  Z_PROPGET_DEF(fileName, QString)
83  Z_PROPGET_DEF(exists, bool)
84  Z_PROPGET_DEF(isReadable, bool)
85  Z_PROPGET_DEF(isWritable, bool)
86  Z_PROPGET_DEF(isExecutable, bool)
87  Z_PROPGET_DEF(isNativePath, bool)
88  Z_PROPGET_DEF(isRelative, bool)
89  Z_PROPGET_DEF(isAbsolute, bool)
90  Z_PROPGET_DEF(isFile, bool)
91  Z_PROPGET_DEF(isDir, bool)
92  Z_PROPGET_DEF(isSymLink, bool)
93  Z_PROPGET_DEF(isBundle, bool)
94  Z_PROPGET_DEF(isHidden, bool)
95  Z_PROPGET_DEF(isRoot, bool)
96  Z_PROPGET_DEF(readLink, QString)
97  Z_PROPGET_DEF(symLinkTarget, QString)
98  Z_PROPGET_DEF(owner, QString)
99  Z_PROPGET_DEF(ownerId, uint)
100  Z_PROPGET_DEF(group, QString)
101  Z_PROPGET_DEF(groupId, uint)
102 
103  Q_PROPERTY(bool caching READ getCaching WRITE setCaching)
104  Q_PROPERTY(QVariant size READ size)
105  Q_PROPERTY(QVariant created READ created)
106  Q_PROPERTY(QVariant lastModified READ lastModified)
107  Q_PROPERTY(QVariant lastRead READ lastRead)
108  Q_PROPERTY(int permissions READ permissions)
109 
110  bool getCaching();
111  void setCaching(bool on);
112  QVariant size() const;
113  QVariant created() const;
114  QVariant lastModified() const;
115  QVariant lastRead() const;
116  int permissions() const;
117 
118 
119  Q_INVOKABLE int inc(); // tbd: change name to "inc" and add "dec";
120  Q_INVOKABLE void setFile(const QString &file);
121  Q_INVOKABLE void refresh();
122  Q_INVOKABLE bool makeAbsolute();
123  Q_INVOKABLE QObject* dir() const;
124  Q_INVOKABLE QObject* absoluteDir() const;
125  Q_INVOKABLE bool permission(int permissions) const;
126 
127 protected:
128 
129  void checkIndex() const;
130 
131  QFileInfoList m_fi;
132  int m_i;
133 };
134 
135 inline void ZFileInfo::checkIndex() const
136 {
137  if(m_i >= m_fi.count())
138  throw ZblException("Index out of range");
139 
140 }
141 
142 
143 
144 
145 } // Zbl
146 
147 #endif /* ZFILEINFO_H_ */
#define ZBLCORESHARED_EXPORT
Access and manipulate file directories. This class is a Javascript wrapper for QDir objects...
Definition: ZDir.h:42
#define Z_PROPGET_DEF(propName, propType)
Definition: zglobal.h:153
Definition: ZAndGate.cpp:6
A Javascript object for passing Zuble file information from C++ to Javascript. This is a wrapper clas...
Definition: ZFileInfo.h:48
Zuble&#39;s Qt Exception Object.
Definition: ZblException.h:45