summaryrefslogtreecommitdiff
path: root/imagelist-item.c
blob: 04b1b7811ebe6b5d0d90bbec3d16dda8c102ee58 (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
58
59
60
#include "imagelist-item.h"

cImageListItem::cImageListItem(const char *lname, const char *sname, eFileInfo type, const 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(const char *lname, const char *sname, eFileInfo type, const char *value, bool hide)
{
  dsyslog("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] != '.') {
    if(0 >= asprintf(&Value, ".%s", value)) {
      return;
    }
  }
  else
    Value = value ? strdup(value) : NULL;

  fType = type;
  HideExt = hide;

  MakeSetupString();

  debug();
}

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