File: webdavfolderlistmodel.h

package info (click to toggle)
lomiri-cloudsync-app 0.8.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,560 kB
  • sloc: cpp: 1,053; python: 67; javascript: 25; makefile: 21; sh: 9
file content (105 lines) | stat: -rw-r--r-- 2,708 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
#ifndef WEBDAVFOLDERLISTMODEL_H
#define WEBDAVFOLDERLISTMODEL_H

#include <QObject>
#include <QAbstractListModel>

//#include "webdav.h"

//webdav stuff
#include <qwebdav.h>
#include <qwebdavdirparser.h>
#include <qwebdavitem.h>



class webdavfolderlistmodel : public QAbstractListModel
{
    Q_OBJECT

    Q_PROPERTY(QString errorMsg READ getErrorMsg NOTIFY errorOccured)
    Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged)
    Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
    Q_PROPERTY(bool showFiles READ showFiles WRITE setShowFiles)
    Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden)
    Q_PROPERTY(int count READ count NOTIFY countChanged)
    Q_PROPERTY(QString username WRITE setUsername NOTIFY credentialsChanged)
    Q_PROPERTY(QString password WRITE setPassword  NOTIFY credentialsChanged)
    Q_PROPERTY(QString serverUrl WRITE setServerUrl NOTIFY credentialsChanged)

public:
    explicit webdavfolderlistmodel (QObject *parent = 0);

    enum Roles { FileNameRole = Qt::UserRole+1,
                 FilePathRole = Qt::UserRole+2
               };

    QHash<int, QByteArray> roleNames() const;

    int rowCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;

    int count() const { return rowCount(QModelIndex()); }

    QString getErrorMsg();

    QString folder();    
    void setFolder(QString &folder);

    void setUsername(QString &username);
    void setPassword(QString &password);
    void setServerUrl(QString &serverUrl);

    bool showDirs();
    void setShowDirs(bool &showDirs);

    bool showFiles();
    void setShowFiles(bool &showFiles);

    bool showHidden();
    void setShowHidden(bool &showHidden);

    Q_INVOKABLE bool isFolder(int index) const;
    Q_INVOKABLE void newWebDavFolder(QString folderPath);

    QString getName(int index) const;
    QString getPath(int index) const;

signals:
    void folderChanged();
    void countChanged();
    void credentialsChanged();
    void errorOccured();

public slots:
    Q_INVOKABLE void getFolderList();

//webdav stuff
//public slots:
    void loadFolderList();
    void printError(QString errorMsg);
    void replySkipRead();

private slots:
    //void modelDataChanged();
    void setWebdavCredentials();

private:
    QString m_folder;
    QString m_errorMsg;
    QString m_username;
    QString m_password;
    QString m_serverUrl;
    bool m_showDirs;
    bool m_showFiles;
    bool m_showHidden;

    //webdav stuff
    QWebdav m_webdav;
    QWebdavDirParser m_parser;
    QString m_path;
    QList<QNetworkReply *> m_replyList;
    QList<QWebdavItem> m_folderList;
};

#endif // WEBDAVFOLDERLISTMODEL_H