Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added folder listing.

  • Loading branch information...
commit b9587a6bdfb0330a6f1b336e9ca8c147b551657d 1 parent 1855075
@ssharunas authored
View
2  Repleisiukas/model/filesystem/ifilesystemobject.h
@@ -19,6 +19,8 @@ class IFileSystemObject : public IRepleisiukasScriptObject
virtual void setName(QString name) = 0;
virtual void setPermissions(Permission* permissions) = 0;
virtual Permission* getPermissions() = 0;
+ virtual QString getPath() = 0;
+
// virtual bool getIsClosed() = 0;
// virtual QString ReadAll() = 0;
View
35 Repleisiukas/model/filesystem/local/localfolderobject.cpp
@@ -78,7 +78,40 @@ Permission *LocalFolderObject::getPermissions()
return permission;
}
+QString LocalFolderObject::getPath()
+{
+ return _dir.absolutePath();
+}
+
+QList<IFileSystemObject *> LocalFolderObject::getFolders()
+{
+ QList<IFileSystemObject *> result;
+
+ QFileInfoList folders = _dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden);
+ foreach (const QFileInfo folder, folders) {
+ result.append(new LocalFolderObject(QUrl(folder.absoluteFilePath()), _mode, _engine));
+ }
+
+ return result;
+}
+
+QList<IFileSystemObject *> LocalFolderObject::getFiles()
+{
+ QList<IFileSystemObject *> result;
+
+ //TODO: finish
+
+ return result;
+}
+
QString LocalFolderObject::toString()
{
- return "[Folder object]";
+ QString permissionsStr;
+ Permission* permissions = getPermissions();
+ if(permissions){
+ permissionsStr = permissions->toString() + " ";
+ permissions->deleteLater();
+ }
+
+ return QString("{%2%1}").arg(getPath()).arg(permissionsStr);
}
View
7 Repleisiukas/model/filesystem/local/localfolderobject.h
@@ -11,6 +11,9 @@ class LocalFolderObject : public FileSystemObject
{
Q_OBJECT
Q_PROPERTY(QString name READ getName WRITE setName)
+ Q_PROPERTY(QString path READ getPath)
+ Q_PROPERTY(QList<IFileSystemObject*> folders READ getFolders)
+ Q_PROPERTY(QList<IFileSystemObject*> files READ getFiles)
Q_PROPERTY(Permission* permissions READ getPermissions WRITE setPermissions)
public:
@@ -23,6 +26,10 @@ class LocalFolderObject : public FileSystemObject
virtual void setPermissions(Permission* permissions);
virtual Permission* getPermissions();
+ virtual QString getPath();
+ QList<IFileSystemObject *> getFolders();
+ QList<IFileSystemObject *> getFiles();
+
signals:
public slots:
View
6 Repleisiukas/presentation/queryexecution.cpp
@@ -11,6 +11,8 @@
#include "../model/qfilesystemaccess.h"
#include "../model/irepleisiukasscriptobject.h"
#include "../model/filesystem/filesystemobject.h"
+#include "../model/filesystem/local/localfolderobject.h"
+#include <QList>
QueryExecution::QueryExecution(QObject *parent) :
QObject(parent), _fileOperations(0)
@@ -94,6 +96,9 @@ QString QueryExecution::LoadExtensions(){
return result;
}
+Q_DECLARE_METATYPE(IFileSystemObject*)
+Q_DECLARE_METATYPE(QList<IFileSystemObject*>)
+
QString QueryExecution::Execute(QString query, QString userInput)
{
QString result;
@@ -111,6 +116,7 @@ QString QueryExecution::Execute(QString query, QString userInput)
QFileSystemAccess* test = new QFileSystemAccess(&engine);
FileSystemObject::registerMetaType(&engine);
Permission::registerMetaType(&engine);
+ qScriptRegisterSequenceMetaType<QList<IFileSystemObject*> >(&engine);
QScriptValue v= engine.newQObject(test, QScriptEngine::ScriptOwnership, QScriptEngine::ExcludeSuperClassContents);
engine.globalObject().setProperty("FS", v);
Please sign in to comment.
Something went wrong with that request. Please try again.