Crossfire Server, Branches 1.12  R18729
CRETreasurePanel.cpp
Go to the documentation of this file.
1 #include <Qt>
2 
3 extern "C" {
4 #include "global.h"
5 #include "treasure.h"
6 }
7 
8 #include "CRETreasurePanel.h"
9 #include "CREUtils.h"
10 
12 {
13  QGridLayout* layout = new QGridLayout(this);
14 
15  myUsing = new QTreeWidget(this);
16  myUsing->setColumnCount(1);
17  myUsing->setHeaderLabel(tr("Used by"));
18  myUsing->setIconSize(QSize(32, 32));
19  layout->addWidget(myUsing, 1, 1);
20 }
21 
23 {
24  myUsing->clear();
25  myTreasure = treas;
26 
27  const archt* arch;
28  QTreeWidgetItem* root = NULL;
29 
30  QString name = myTreasure->name;
31 
32  for (arch = first_archetype; arch; arch = arch->more ? arch->more : arch->next)
33  {
34  if (arch->clone.randomitems && name == arch->clone.randomitems->name)
35  {
36  if (root == NULL)
37  {
38  root = CREUtils::archetypeNode(NULL);
39  myUsing->addTopLevelItem(root);
40  root->setExpanded(true);
41  }
42  CREUtils::archetypeNode(arch, root);
43  }
44  }
45 
46  root = NULL;
47 
48  const treasurelist* list;
49  const treasure* t;
50 
51  for (list = first_treasurelist; list; list = list->next)
52  {
53  for (t = list->items; t; t = t->next)
54  {
55  if (t->name == name)
56  {
57  if (root == NULL)
58  {
59  root = CREUtils::treasureNode(NULL);
60  myUsing->addTopLevelItem(root);
61  root->setExpanded(true);
62  }
63  CREUtils::treasureNode(list, root);
64  }
65  }
66  }
67 }
static QTreeWidgetItem * archetypeNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:11
struct treasureliststruct * randomitems
Definition: object.h:236
object clone
Definition: object.h:326
struct treasureliststruct * next
Definition: treasure.h:118
Definition: object.h:321
static char root[500]
Definition: mapper.c:361
QTreeWidget * myUsing
struct archt * more
Definition: object.h:325
const treasurelist * myTreasure
EXTERN treasurelist * first_treasurelist
Definition: global.h:193
struct treasurestruct * items
Definition: treasure.h:119
const char * name
Definition: treasure.h:112
void setTreasure(const treasurelist *treasure)
struct archt * next
Definition: object.h:323
static QTreeWidgetItem * treasureNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:64
struct treasurestruct * next
Definition: treasure.h:95
const char * name
Definition: treasure.h:94
EXTERN archetype * first_archetype
Definition: global.h:195