~ubuntu-filemanager-dev/ubuntu-filemanager-app/trunk

« back to all changes in this revision

Viewing changes to src/plugin/folderlistmodel/iorequest.h

  • Committer: Bileto Bot
  • Date: 2017-04-04 17:06:41 UTC
  • mfrom: (588.1.19 fix-desktop-file)
  • Revision ID: ci-train-bot@canonical.com-20170404170641-1p15lmx8wodlx2ut
* Rename binary file to ubuntu-filemanager-app
* Join plugin packages into the main package 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Robin Burchell <robin+nemo@viroteck.net>
 
3
 *
 
4
 * You may use this file under the terms of the BSD license as follows:
 
5
 *
 
6
 * "Redistribution and use in source and binary forms, with or without
 
7
 * modification, are permitted provided that the following conditions are
 
8
 * met:
 
9
 *   * Redistributions of source code must retain the above copyright
 
10
 *     notice, this list of conditions and the following disclaimer.
 
11
 *   * Redistributions in binary form must reproduce the above copyright
 
12
 *     notice, this list of conditions and the following disclaimer in
 
13
 *     the documentation and/or other materials provided with the
 
14
 *     distribution.
 
15
 *   * Neither the name of Nemo Mobile nor the names of its contributors
 
16
 *     may be used to endorse or promote products derived from this
 
17
 *     software without specific prior written permission.
 
18
 *
 
19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
20
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
21
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
22
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
23
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
24
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
25
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
26
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
27
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
28
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
29
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 
30
 */
 
31
 
 
32
#ifndef IOREQUEST_H
 
33
#define IOREQUEST_H
 
34
 
 
35
#include "diriteminfo.h"
 
36
 
 
37
#include <QHash>
 
38
#include <QDir>
 
39
 
 
40
class IORequest : public QObject
 
41
{
 
42
    Q_OBJECT
 
43
public:   
 
44
    explicit IORequest();
 
45
    virtual ~IORequest();
 
46
    
 
47
public:
 
48
    enum RequestType
 
49
    {
 
50
        DirList,
 
51
        DirListExternalFSChanges,
 
52
        SambaList
 
53
    };
 
54
    virtual void run() = 0;
 
55
    RequestType  type() const;
 
56
    
 
57
private:
 
58
    // hide this because IORequest should *NOT* be parented directly
 
59
    using QObject::setParent;
 
60
 
 
61
protected:
 
62
    RequestType  m_type;
 
63
};
 
64
 
 
65
 
 
66
 
 
67
class IORequestLoader : public IORequest
 
68
{
 
69
 Q_OBJECT
 
70
public:
 
71
    enum LoaderType
 
72
    {
 
73
        NormalLoader,
 
74
        TrashLoader,
 
75
        NetworkLoader
 
76
    };
 
77
 
 
78
    IORequestLoader( const QString &pathName,
 
79
                     QDir::Filters filter,
 
80
                     bool isRecursive
 
81
                   );
 
82
    IORequestLoader( const QString& trashRootDir,
 
83
                     const QString &pathName,
 
84
                     QDir::Filters filter,
 
85
                     bool isRecursive
 
86
                   );                   
 
87
    virtual ~IORequestLoader();
 
88
    DirItemInfoList     getContents();
 
89
 
 
90
signals:
 
91
    void itemsAdded(const DirItemInfoList &files);
 
92
 
 
93
private:
 
94
    DirItemInfoList getNormalContent();
 
95
    DirItemInfoList getTrashContent();
 
96
    virtual DirItemInfoList getNetworkContent();
 
97
    DirItemInfoList add(const QString &pathName, QDir::Filters filter,
 
98
                        bool isRecursive, DirItemInfoList directoryContents);
 
99
protected:
 
100
    LoaderType    mLoaderType;
 
101
    QString       mPathName;
 
102
    QDir::Filters mFilter;
 
103
    bool          mIsRecursive;
 
104
    QString       mTtrashRootDir;
 
105
};
 
106
 
 
107
 
 
108
 
 
109
 
 
110
class DirListWorker : public IORequestLoader
 
111
{
 
112
    Q_OBJECT
 
113
public:
 
114
    explicit DirListWorker(const QString &pathName, QDir::Filters filter, const bool isRecursive);
 
115
    explicit DirListWorker(const QString& trashRootDir, const QString &pathName, QDir::Filters filter, const bool isRecursive);
 
116
    virtual ~DirListWorker();
 
117
    void run();
 
118
protected:
 
119
signals:
 
120
    void workerFinished();
 
121
 
 
122
};
 
123
 
 
124
 
 
125
 
 
126
 
 
127
class TrashListWorker  : public DirListWorker
 
128
{
 
129
    Q_OBJECT
 
130
public:
 
131
    explicit TrashListWorker(const QString &trashRoot, const QString& path, QDir::Filters filter);
 
132
    virtual ~TrashListWorker();
 
133
};
 
134
 
 
135
 
 
136
 
 
137
class  ExternalFileSystemChangesWorker : public IORequestLoader
 
138
{
 
139
    Q_OBJECT
 
140
public:
 
141
    explicit ExternalFileSystemChangesWorker(const DirItemInfoList& content,
 
142
                                      const QString &pathName,
 
143
                                      QDir::Filters filter,
 
144
                                      const bool isRecursive);
 
145
    virtual ~ExternalFileSystemChangesWorker();
 
146
    void     run();
 
147
 
 
148
protected:
 
149
    int  compareItems(const DirItemInfoList& contentNew);
 
150
 
 
151
signals:
 
152
    void     removed(const DirItemInfo&);
 
153
    void     changed(const DirItemInfo&);
 
154
    void     added(const   DirItemInfo& );
 
155
    void     finished(int);
 
156
private:
 
157
    QHash<QString, DirItemInfo>    m_curContent;   //!< using hash because the vector can be in any order
 
158
};
 
159
 
 
160
 
 
161
 
 
162
class ExternalFileSystemTrashChangesWorker : public ExternalFileSystemChangesWorker
 
163
{
 
164
 Q_OBJECT
 
165
 
 
166
public:
 
167
  ExternalFileSystemTrashChangesWorker(const QStringList& pathNames,
 
168
                                       const DirItemInfoList& list,
 
169
                                       QDir::Filters filter);
 
170
  virtual ~ExternalFileSystemTrashChangesWorker();
 
171
  void run();
 
172
private:
 
173
  QStringList    m_pathList;
 
174
};
 
175
 
 
176
 
 
177
 
 
178
#endif // IOREQUEST_H