-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiconos.h
More file actions
75 lines (68 loc) · 2.08 KB
/
iconos.h
File metadata and controls
75 lines (68 loc) · 2.08 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
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
#ifndef ICONOS_H
#define ICONOS_H
#include <map>
#include <QIcon>
#include <QDebug>
#include "./defs.h"
//enum class Naturaleza{SIN_CLASIFICAR, MANO_DE_OBRA, MAQUINARIA, MATERIALES, COMP_RESIDUO,CLASIF_RESIDUO, CAPITULO, PARTIDA};
using IconsMap = std::map<Naturaleza,QIcon>;
class RepoIconos
{
private:
static IconsMap _iconos;
static IconsMap initMap()
{
return
{
std::make_pair(Naturaleza::SIN_CLASIFICAR, QIcon(QStringLiteral(":/Iconos/sinclasificar.png"))),
std::make_pair(Naturaleza::MANO_DE_OBRA, QIcon(QStringLiteral(":/Iconos/engineer.png"))),
std::make_pair(Naturaleza::MAQUINARIA, QIcon(QStringLiteral(":/Iconos/trucking.png"))),
std::make_pair(Naturaleza::MATERIALES, QIcon(QStringLiteral(":/Iconos/brick.png"))),
std::make_pair(Naturaleza::COMP_RESIDUO, QIcon(QStringLiteral(":/Iconos/delete.png"))),
std::make_pair(Naturaleza::CLASIF_RESIDUO, QIcon(QStringLiteral(":/Iconos/delete.png"))),
std::make_pair(Naturaleza::CAPITULO, QIcon(QStringLiteral(":/Iconos/folder.png"))),
std::make_pair(Naturaleza::PARTIDA, QIcon(QStringLiteral(":/Iconos/file.png")))
};
}
public:
RepoIconos()=delete;//no debe haber constructor disponible al ser clase estática
static QIcon GetIcon(Naturaleza type)
{
if(_iconos.empty())
{
_iconos = initMap();
}
auto it = _iconos.find(type);
if(it == _iconos.end())
{
it = _iconos.find(Naturaleza::SIN_CLASIFICAR);
}
return it->second;
}
static QIcon GetIcon(int pos)
{
if(_iconos.empty())
{
_iconos = initMap();
}
auto it = _iconos.begin();
for (int i=0;i<pos;i++)
{
it++;
}
return it->second;
}
static int tam()
{
if(_iconos.empty())
{
_iconos = initMap();
}
return _iconos.size();
}
};
namespace DatosIconos
{
static const int ImageIndexRole = Qt::UserRole+1;
}
#endif // ICONOS_H