summaryrefslogtreecommitdiff
path: root/imagelist-item.c
blob: 95a2cb278c2d7afd55acf55b20bd8f1ecbe85d5a (plain)
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
#include "imagelist-item.h"

cImageListItem::cImageListItem(char *lname, char *sname, eFileInfo type, char *value, bool hide)
{
  LName = NULL;
  SName = NULL;
  Value = 0;
  SString = NULL;

  Edit(lname, sname, type, value, hide);

  Debug();
}

cImageListItem::~ cImageListItem(void)
{
  free(LName);
  free(SName);
  free(Value);
  free(SString);
}

void cImageListItem::Edit(char *lname, char *sname, eFileInfo type, char *value, bool hide)
{
  DEBUG("New/Edit ImageListItem");
  Debug();

  free(LName);
  free(SName);
  free(Value);

  LName = lname ? strdup(lname) : NULL;
  SName = sname ? strdup(sname) : NULL;

  if(type == tFile && value && value[0] != '.')
    asprintf(&Value, ".%s", value);
  else
    Value = value ? strdup(value) : NULL;

  fType = type;
  HideExt = hide;

  MakeSetupString();

  Debug();
}

void cImageListItem::Debug(void)
{
  DEBUG("Items:");
  DEBUG("  LongName: %s", LName);
  DEBUG("  ShortName: %s", SName);
  DEBUG("  FileType: %i", (int)fType);
  DEBUG("  Value: %s", Value);
  DEBUG("  Hide: %s", HideExt ? "TRUE" : "FALSE");
  DEBUG("  SaveString: %s", SString);
}