workman161 / glovebox

An in-car assistant built with Qt Embedded Linux.

This URL has Read+Write access

glovebox / gloveui / GStandardDirs.h
100644 45 lines (36 sloc) 0.969 kb
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
#ifndef GSTANDARDDIRS_H
#define GSTANDARDDIRS_H
 
#include <QString>
#include <QStringList>
#include <QMap>
#include <QCache>
 
#include "Glovebox.h"
 
namespace Glovebox
{
 
class GStandardDirs {
  public:
    GStandardDirs();
    ~GStandardDirs();
    QStringList findFiles(const QString &type, const QString &file);
    QString findFile(const QString &type, const QString &file);
    static GStandardDirs* global() {
      static GStandardDirs* instance;
      if (instance == 0)
        instance = new GStandardDirs();
      return instance;
    }
    
    /**
* @brief Adds a resource type and its relative directory
*/
    void addResourceType(const char * type, const char * relativePath);
    
    /**
* @brief Adds a path to the list of directories to search for resources
*/
    void addPrefix(const QString &prefix);
 
  private:
    QStringList prefixes;
    QHash<QString, QString> types;
    QHash<QString, QStringList> cache;
};
 
}
 
#endif