filesearchpath.h
1 //------------------------------------------------------------------------------
2 // filesearchpath.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2013 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef idD5CA37A7_5FD3_4151_8316AB0B1F9974E5
24 #define idD5CA37A7_5FD3_4151_8316AB0B1F9974E5
25 
26 #include <QList>
27 #include <QSet>
28 #include <QString>
29 #include <QVariant>
30 
32 
34 {
35 public:
36  static QList<FileSearchPath> fromStringList(const QStringList &collection);
37  static FileSearchPath fromVariant(const QVariant &var);
38  static QList<FileSearchPath> fromVariantList(const QVariantList &collection);
39  static QVariantList toVariantList(const QList<FileSearchPath> &collection);
40  static FileSearchPath resolveTemplated(TemplatedPathResolver &resolver,
41  const FileSearchPath &path);
42  static QList<FileSearchPath> resolveTemplated(TemplatedPathResolver &resolver,
43  const QList<FileSearchPath> &paths);
44 
50  static void merge(QList<FileSearchPath> &paths);
51 
53  FileSearchPath(const QString &path);
54 
55  bool isRecursive() const
56  {
57  return recursive_;
58  }
59 
60  bool isValid() const;
61  QVariant toVariant() const;
62 
63  const QString &path() const
64  {
65  return path_;
66  }
67 
68  void setPath(const QString &path)
69  {
70  path_ = path;
71  }
72 
73  void setRecursive(bool b)
74  {
75  recursive_ = b;
76  }
77 
84  void setCache(const QMap<QString, QString> &files);
85  bool hasCache();
86  const QMap<QString, QString> &getCache();
87 
94  bool contains(const QString &path) const;
95 private:
96  QString path_;
97  bool recursive_;
98  QMap<QString, QString> cacheFiles_;
99 };
100 
101 #endif